Commit 4a956bd2 authored by David S. Miller's avatar David S. Miller

Merge branch 'DPAA-Ethernet-changes'

Madalin Bucur says:

====================
DPAA Ethernet changes

v2: remove excess braces

Here are some more changes for the DPAA 1.x area.
In summary, these changes use pages for the receive buffers and
for the scatter-gather table fed to the HW on the Tx path, perform
a bit of cleanup in some convoluted parts of the code, add some
minor fixes related to DMA (un)mapping sequencing for a not so
common scenario, add a device link that removes the interfaces
when the QMan portal in use by them is removed.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2bd7c3e1 e06eea55
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
/* Total number of Tx queues */ /* Total number of Tx queues */
#define DPAA_ETH_TXQ_NUM (DPAA_TC_NUM * DPAA_TC_TXQ_NUM) #define DPAA_ETH_TXQ_NUM (DPAA_TC_NUM * DPAA_TC_TXQ_NUM)
#define DPAA_BPS_NUM 3 /* number of bpools per interface */
/* More detailed FQ types - used for fine-grained WQ assignments */ /* More detailed FQ types - used for fine-grained WQ assignments */
enum dpaa_fq_type { enum dpaa_fq_type {
FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */ FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */
...@@ -148,7 +146,7 @@ struct dpaa_buffer_layout { ...@@ -148,7 +146,7 @@ struct dpaa_buffer_layout {
struct dpaa_priv { struct dpaa_priv {
struct dpaa_percpu_priv __percpu *percpu_priv; struct dpaa_percpu_priv __percpu *percpu_priv;
struct dpaa_bp *dpaa_bps[DPAA_BPS_NUM]; struct dpaa_bp *dpaa_bp;
/* Store here the needed Tx headroom for convenience and speed /* Store here the needed Tx headroom for convenience and speed
* (even though it can be computed based on the fields of buf_layout) * (even though it can be computed based on the fields of buf_layout)
*/ */
......
...@@ -131,11 +131,9 @@ static ssize_t dpaa_eth_show_bpids(struct device *dev, ...@@ -131,11 +131,9 @@ static ssize_t dpaa_eth_show_bpids(struct device *dev,
{ {
struct dpaa_priv *priv = netdev_priv(to_net_dev(dev)); struct dpaa_priv *priv = netdev_priv(to_net_dev(dev));
ssize_t bytes = 0; ssize_t bytes = 0;
int i = 0;
for (i = 0; i < DPAA_BPS_NUM; i++) bytes += snprintf(buf + bytes, PAGE_SIZE - bytes, "%u\n",
bytes += snprintf(buf + bytes, PAGE_SIZE - bytes, "%u\n", priv->dpaa_bp->bpid);
priv->dpaa_bps[i]->bpid);
return bytes; return bytes;
} }
......
...@@ -47,6 +47,8 @@ static const char dpaa_stats_percpu[][ETH_GSTRING_LEN] = { ...@@ -47,6 +47,8 @@ static const char dpaa_stats_percpu[][ETH_GSTRING_LEN] = {
"tx S/G", "tx S/G",
"tx error", "tx error",
"rx error", "rx error",
"rx dropped",
"tx dropped",
}; };
static char dpaa_stats_global[][ETH_GSTRING_LEN] = { static char dpaa_stats_global[][ETH_GSTRING_LEN] = {
...@@ -78,10 +80,8 @@ static char dpaa_stats_global[][ETH_GSTRING_LEN] = { ...@@ -78,10 +80,8 @@ static char dpaa_stats_global[][ETH_GSTRING_LEN] = {
static int dpaa_get_link_ksettings(struct net_device *net_dev, static int dpaa_get_link_ksettings(struct net_device *net_dev,
struct ethtool_link_ksettings *cmd) struct ethtool_link_ksettings *cmd)
{ {
if (!net_dev->phydev) { if (!net_dev->phydev)
netdev_dbg(net_dev, "phy device not initialized\n");
return 0; return 0;
}
phy_ethtool_ksettings_get(net_dev->phydev, cmd); phy_ethtool_ksettings_get(net_dev->phydev, cmd);
...@@ -93,10 +93,8 @@ static int dpaa_set_link_ksettings(struct net_device *net_dev, ...@@ -93,10 +93,8 @@ static int dpaa_set_link_ksettings(struct net_device *net_dev,
{ {
int err; int err;
if (!net_dev->phydev) { if (!net_dev->phydev)
netdev_err(net_dev, "phy device not initialized\n");
return -ENODEV; return -ENODEV;
}
err = phy_ethtool_ksettings_set(net_dev->phydev, cmd); err = phy_ethtool_ksettings_set(net_dev->phydev, cmd);
if (err < 0) if (err < 0)
...@@ -140,10 +138,8 @@ static int dpaa_nway_reset(struct net_device *net_dev) ...@@ -140,10 +138,8 @@ static int dpaa_nway_reset(struct net_device *net_dev)
{ {
int err; int err;
if (!net_dev->phydev) { if (!net_dev->phydev)
netdev_err(net_dev, "phy device not initialized\n");
return -ENODEV; return -ENODEV;
}
err = 0; err = 0;
if (net_dev->phydev->autoneg) { if (net_dev->phydev->autoneg) {
...@@ -165,10 +161,8 @@ static void dpaa_get_pauseparam(struct net_device *net_dev, ...@@ -165,10 +161,8 @@ static void dpaa_get_pauseparam(struct net_device *net_dev,
priv = netdev_priv(net_dev); priv = netdev_priv(net_dev);
mac_dev = priv->mac_dev; mac_dev = priv->mac_dev;
if (!net_dev->phydev) { if (!net_dev->phydev)
netdev_err(net_dev, "phy device not initialized\n");
return; return;
}
epause->autoneg = mac_dev->autoneg_pause; epause->autoneg = mac_dev->autoneg_pause;
epause->rx_pause = mac_dev->rx_pause_active; epause->rx_pause = mac_dev->rx_pause_active;
...@@ -223,7 +217,7 @@ static int dpaa_get_sset_count(struct net_device *net_dev, int type) ...@@ -223,7 +217,7 @@ static int dpaa_get_sset_count(struct net_device *net_dev, int type)
unsigned int total_stats, num_stats; unsigned int total_stats, num_stats;
num_stats = num_online_cpus() + 1; num_stats = num_online_cpus() + 1;
total_stats = num_stats * (DPAA_STATS_PERCPU_LEN + DPAA_BPS_NUM) + total_stats = num_stats * (DPAA_STATS_PERCPU_LEN + 1) +
DPAA_STATS_GLOBAL_LEN; DPAA_STATS_GLOBAL_LEN;
switch (type) { switch (type) {
...@@ -235,10 +229,10 @@ static int dpaa_get_sset_count(struct net_device *net_dev, int type) ...@@ -235,10 +229,10 @@ static int dpaa_get_sset_count(struct net_device *net_dev, int type)
} }
static void copy_stats(struct dpaa_percpu_priv *percpu_priv, int num_cpus, static void copy_stats(struct dpaa_percpu_priv *percpu_priv, int num_cpus,
int crr_cpu, u64 *bp_count, u64 *data) int crr_cpu, u64 bp_count, u64 *data)
{ {
int num_values = num_cpus + 1; int num_values = num_cpus + 1;
int crr = 0, j; int crr = 0;
/* update current CPU's stats and also add them to the total values */ /* update current CPU's stats and also add them to the total values */
data[crr * num_values + crr_cpu] = percpu_priv->in_interrupt; data[crr * num_values + crr_cpu] = percpu_priv->in_interrupt;
...@@ -262,23 +256,27 @@ static void copy_stats(struct dpaa_percpu_priv *percpu_priv, int num_cpus, ...@@ -262,23 +256,27 @@ static void copy_stats(struct dpaa_percpu_priv *percpu_priv, int num_cpus,
data[crr * num_values + crr_cpu] = percpu_priv->stats.rx_errors; data[crr * num_values + crr_cpu] = percpu_priv->stats.rx_errors;
data[crr++ * num_values + num_cpus] += percpu_priv->stats.rx_errors; data[crr++ * num_values + num_cpus] += percpu_priv->stats.rx_errors;
for (j = 0; j < DPAA_BPS_NUM; j++) { data[crr * num_values + crr_cpu] = percpu_priv->stats.rx_dropped;
data[crr * num_values + crr_cpu] = bp_count[j]; data[crr++ * num_values + num_cpus] += percpu_priv->stats.rx_dropped;
data[crr++ * num_values + num_cpus] += bp_count[j];
} data[crr * num_values + crr_cpu] = percpu_priv->stats.tx_dropped;
data[crr++ * num_values + num_cpus] += percpu_priv->stats.tx_dropped;
data[crr * num_values + crr_cpu] = bp_count;
data[crr++ * num_values + num_cpus] += bp_count;
} }
static void dpaa_get_ethtool_stats(struct net_device *net_dev, static void dpaa_get_ethtool_stats(struct net_device *net_dev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
u64 bp_count[DPAA_BPS_NUM], cg_time, cg_num;
struct dpaa_percpu_priv *percpu_priv; struct dpaa_percpu_priv *percpu_priv;
struct dpaa_rx_errors rx_errors; struct dpaa_rx_errors rx_errors;
unsigned int num_cpus, offset; unsigned int num_cpus, offset;
u64 bp_count, cg_time, cg_num;
struct dpaa_ern_cnt ern_cnt; struct dpaa_ern_cnt ern_cnt;
struct dpaa_bp *dpaa_bp; struct dpaa_bp *dpaa_bp;
struct dpaa_priv *priv; struct dpaa_priv *priv;
int total_stats, i, j; int total_stats, i;
bool cg_status; bool cg_status;
total_stats = dpaa_get_sset_count(net_dev, ETH_SS_STATS); total_stats = dpaa_get_sset_count(net_dev, ETH_SS_STATS);
...@@ -292,12 +290,10 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev, ...@@ -292,12 +290,10 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev,
for_each_online_cpu(i) { for_each_online_cpu(i) {
percpu_priv = per_cpu_ptr(priv->percpu_priv, i); percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
for (j = 0; j < DPAA_BPS_NUM; j++) { dpaa_bp = priv->dpaa_bp;
dpaa_bp = priv->dpaa_bps[j]; if (!dpaa_bp->percpu_count)
if (!dpaa_bp->percpu_count) continue;
continue; bp_count = *(per_cpu_ptr(dpaa_bp->percpu_count, i));
bp_count[j] = *(per_cpu_ptr(dpaa_bp->percpu_count, i));
}
rx_errors.dme += percpu_priv->rx_errors.dme; rx_errors.dme += percpu_priv->rx_errors.dme;
rx_errors.fpe += percpu_priv->rx_errors.fpe; rx_errors.fpe += percpu_priv->rx_errors.fpe;
rx_errors.fse += percpu_priv->rx_errors.fse; rx_errors.fse += percpu_priv->rx_errors.fse;
...@@ -315,7 +311,7 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev, ...@@ -315,7 +311,7 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev,
copy_stats(percpu_priv, num_cpus, i, bp_count, data); copy_stats(percpu_priv, num_cpus, i, bp_count, data);
} }
offset = (num_cpus + 1) * (DPAA_STATS_PERCPU_LEN + DPAA_BPS_NUM); offset = (num_cpus + 1) * (DPAA_STATS_PERCPU_LEN + 1);
memcpy(data + offset, &rx_errors, sizeof(struct dpaa_rx_errors)); memcpy(data + offset, &rx_errors, sizeof(struct dpaa_rx_errors));
offset += sizeof(struct dpaa_rx_errors) / sizeof(u64); offset += sizeof(struct dpaa_rx_errors) / sizeof(u64);
...@@ -363,18 +359,16 @@ static void dpaa_get_strings(struct net_device *net_dev, u32 stringset, ...@@ -363,18 +359,16 @@ static void dpaa_get_strings(struct net_device *net_dev, u32 stringset,
memcpy(strings, string_cpu, ETH_GSTRING_LEN); memcpy(strings, string_cpu, ETH_GSTRING_LEN);
strings += ETH_GSTRING_LEN; strings += ETH_GSTRING_LEN;
} }
for (i = 0; i < DPAA_BPS_NUM; i++) { for (j = 0; j < num_cpus; j++) {
for (j = 0; j < num_cpus; j++) { snprintf(string_cpu, ETH_GSTRING_LEN,
snprintf(string_cpu, ETH_GSTRING_LEN, "bpool [CPU %d]", j);
"bpool %c [CPU %d]", 'a' + i, j);
memcpy(strings, string_cpu, ETH_GSTRING_LEN);
strings += ETH_GSTRING_LEN;
}
snprintf(string_cpu, ETH_GSTRING_LEN, "bpool %c [TOTAL]",
'a' + i);
memcpy(strings, string_cpu, ETH_GSTRING_LEN); memcpy(strings, string_cpu, ETH_GSTRING_LEN);
strings += ETH_GSTRING_LEN; strings += ETH_GSTRING_LEN;
} }
snprintf(string_cpu, ETH_GSTRING_LEN, "bpool [TOTAL]");
memcpy(strings, string_cpu, ETH_GSTRING_LEN);
strings += ETH_GSTRING_LEN;
memcpy(strings, dpaa_stats_global, size); memcpy(strings, dpaa_stats_global, size);
} }
......
...@@ -1749,6 +1749,13 @@ struct qman_portal *qman_get_affine_portal(int cpu) ...@@ -1749,6 +1749,13 @@ struct qman_portal *qman_get_affine_portal(int cpu)
} }
EXPORT_SYMBOL(qman_get_affine_portal); EXPORT_SYMBOL(qman_get_affine_portal);
int qman_start_using_portal(struct qman_portal *p, struct device *dev)
{
return (!device_link_add(dev, p->config->dev,
DL_FLAG_AUTOREMOVE_CONSUMER)) ? -EINVAL : 0;
}
EXPORT_SYMBOL(qman_start_using_portal);
int qman_p_poll_dqrr(struct qman_portal *p, unsigned int limit) int qman_p_poll_dqrr(struct qman_portal *p, unsigned int limit)
{ {
return __poll_portal_fast(p, limit); return __poll_portal_fast(p, limit);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define __FSL_QMAN_H #define __FSL_QMAN_H
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/device.h>
/* Hardware constants */ /* Hardware constants */
#define QM_CHANNEL_SWPORTAL0 0 #define QM_CHANNEL_SWPORTAL0 0
...@@ -914,6 +915,16 @@ u16 qman_affine_channel(int cpu); ...@@ -914,6 +915,16 @@ u16 qman_affine_channel(int cpu);
*/ */
struct qman_portal *qman_get_affine_portal(int cpu); struct qman_portal *qman_get_affine_portal(int cpu);
/**
* qman_start_using_portal - register a device link for the portal user
* @p: the portal that will be in use
* @dev: the device that will use the portal
*
* Makes sure that the devices that use the portal are unbound when the
* portal is unbound
*/
int qman_start_using_portal(struct qman_portal *p, struct device *dev);
/** /**
* qman_p_poll_dqrr - process DQRR (fast-path) entries * qman_p_poll_dqrr - process DQRR (fast-path) entries
* @limit: the maximum number of DQRR entries to process * @limit: the maximum number of DQRR entries to process
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment