Skip to content

Commit 569dac6

Browse files
Ioana Ciocoi Radulescudavem330
authored andcommitted
dpaa2-eth: bql support
Add support for byte queue limit. On NAPI poll, we save the total number of Tx confirmed frames/bytes and register them with bql at the end of the poll function. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dbcdf72 commit 569dac6

File tree

2 files changed

+46
-15
lines changed

2 files changed

+46
-15
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
288288
* Observance of NAPI budget is not our concern, leaving that to the caller.
289289
*/
290290
static int consume_frames(struct dpaa2_eth_channel *ch,
291-
enum dpaa2_eth_fq_type *type)
291+
struct dpaa2_eth_fq **src)
292292
{
293293
struct dpaa2_eth_priv *priv = ch->priv;
294294
struct dpaa2_eth_fq *fq = NULL;
@@ -322,10 +322,10 @@ static int consume_frames(struct dpaa2_eth_channel *ch,
322322
ch->stats.frames += cleaned;
323323

324324
/* A dequeue operation only pulls frames from a single queue
325-
* into the store. Return the frame queue type as an out param.
325+
* into the store. Return the frame queue as an out param.
326326
*/
327-
if (type)
328-
*type = fq->type;
327+
if (src)
328+
*src = fq;
329329

330330
return cleaned;
331331
}
@@ -570,8 +570,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
570570
struct rtnl_link_stats64 *percpu_stats;
571571
struct dpaa2_eth_drv_stats *percpu_extras;
572572
struct dpaa2_eth_fq *fq;
573+
struct netdev_queue *nq;
573574
u16 queue_mapping;
574575
unsigned int needed_headroom;
576+
u32 fd_len;
575577
int err, i;
576578

577579
percpu_stats = this_cpu_ptr(priv->percpu_stats);
@@ -643,8 +645,12 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
643645
/* Clean up everything, including freeing the skb */
644646
free_tx_fd(priv, &fd);
645647
} else {
648+
fd_len = dpaa2_fd_get_len(&fd);
646649
percpu_stats->tx_packets++;
647-
percpu_stats->tx_bytes += dpaa2_fd_get_len(&fd);
650+
percpu_stats->tx_bytes += fd_len;
651+
652+
nq = netdev_get_tx_queue(net_dev, queue_mapping);
653+
netdev_tx_sent_queue(nq, fd_len);
648654
}
649655

650656
return NETDEV_TX_OK;
@@ -660,18 +666,22 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
660666
static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
661667
struct dpaa2_eth_channel *ch __always_unused,
662668
const struct dpaa2_fd *fd,
663-
struct dpaa2_eth_fq *fq __always_unused)
669+
struct dpaa2_eth_fq *fq)
664670
{
665671
struct rtnl_link_stats64 *percpu_stats;
666672
struct dpaa2_eth_drv_stats *percpu_extras;
673+
u32 fd_len = dpaa2_fd_get_len(fd);
667674
u32 fd_errors;
668675

669676
/* Tracing point */
670677
trace_dpaa2_tx_conf_fd(priv->net_dev, fd);
671678

672679
percpu_extras = this_cpu_ptr(priv->percpu_extras);
673680
percpu_extras->tx_conf_frames++;
674-
percpu_extras->tx_conf_bytes += dpaa2_fd_get_len(fd);
681+
percpu_extras->tx_conf_bytes += fd_len;
682+
683+
fq->dq_frames++;
684+
fq->dq_bytes += fd_len;
675685

676686
/* Check frame errors in the FD field */
677687
fd_errors = dpaa2_fd_get_ctrl(fd) & DPAA2_FD_TX_ERR_MASK;
@@ -932,8 +942,9 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget)
932942
struct dpaa2_eth_channel *ch;
933943
struct dpaa2_eth_priv *priv;
934944
int rx_cleaned = 0, txconf_cleaned = 0;
935-
enum dpaa2_eth_fq_type type = 0;
936-
int store_cleaned;
945+
struct dpaa2_eth_fq *fq, *txc_fq = NULL;
946+
struct netdev_queue *nq;
947+
int store_cleaned, work_done;
937948
int err;
938949

939950
ch = container_of(napi, struct dpaa2_eth_channel, napi);
@@ -947,18 +958,25 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget)
947958
/* Refill pool if appropriate */
948959
refill_pool(priv, ch, priv->bpid);
949960

950-
store_cleaned = consume_frames(ch, &type);
951-
if (type == DPAA2_RX_FQ)
961+
store_cleaned = consume_frames(ch, &fq);
962+
if (!store_cleaned)
963+
break;
964+
if (fq->type == DPAA2_RX_FQ) {
952965
rx_cleaned += store_cleaned;
953-
else
966+
} else {
954967
txconf_cleaned += store_cleaned;
968+
/* We have a single Tx conf FQ on this channel */
969+
txc_fq = fq;
970+
}
955971

956972
/* If we either consumed the whole NAPI budget with Rx frames
957973
* or we reached the Tx confirmations threshold, we're done.
958974
*/
959975
if (rx_cleaned >= budget ||
960-
txconf_cleaned >= DPAA2_ETH_TXCONF_PER_NAPI)
961-
return budget;
976+
txconf_cleaned >= DPAA2_ETH_TXCONF_PER_NAPI) {
977+
work_done = budget;
978+
goto out;
979+
}
962980
} while (store_cleaned);
963981

964982
/* We didn't consume the entire budget, so finish napi and
@@ -972,7 +990,18 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget)
972990
WARN_ONCE(err, "CDAN notifications rearm failed on core %d",
973991
ch->nctx.desired_cpu);
974992

975-
return max(rx_cleaned, 1);
993+
work_done = max(rx_cleaned, 1);
994+
995+
out:
996+
if (txc_fq) {
997+
nq = netdev_get_tx_queue(priv->net_dev, txc_fq->flowid);
998+
netdev_tx_completed_queue(nq, txc_fq->dq_frames,
999+
txc_fq->dq_bytes);
1000+
txc_fq->dq_frames = 0;
1001+
txc_fq->dq_bytes = 0;
1002+
}
1003+
1004+
return work_done;
9761005
}
9771006

9781007
static void enable_ch_napi(struct dpaa2_eth_priv *priv)

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ struct dpaa2_eth_fq {
271271
u32 tx_qdbin;
272272
u16 flowid;
273273
int target_cpu;
274+
u32 dq_frames;
275+
u32 dq_bytes;
274276
struct dpaa2_eth_channel *channel;
275277
enum dpaa2_eth_fq_type type;
276278

0 commit comments

Comments
 (0)