* [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup
@ 2025-02-17 7:31 Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
We have 2 tx completion functions to handle single-port vs multi-port
variants. Merge them into one function to make maintenance easier.
We also have 2 functions to handle TX completion for SKB vs XDP.
Get rid of them too.
Also do some minor cleanups.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
Roger Quadros (5):
net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()
net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp
net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp()
net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp()
net: ethernet: ti am65_cpsw: Drop separate TX completion functions
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 211 +++++++++----------------------
drivers/net/ethernet/ti/am65-cpsw-nuss.h | 8 ++
2 files changed, 71 insertions(+), 148 deletions(-)
---
base-commit: 489b31c6cf29fff5b1f5c48625770f45cea90ada
change-id: 20250214-am65-cpsw-zc-prep-038276579e73
Best regards,
--
Roger Quadros <rogerq@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
@ 2025-02-17 7:31 ` Roger Quadros
2025-02-18 18:01 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp Roger Quadros
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
The only difference between am65_cpsw_nuss_tx_compl_packets_2g() and
am65_cpsw_nuss_tx_compl_packets() is the usage of spin_lock() and
netdev_tx_completed_queue() + am65_cpsw_nuss_tx_wake at every packet
in the latter.
Insted of having 2 separate functions for TX completion, merge them
into one. This will reduce code duplication and make maintenance easier.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 98 ++++++++------------------------
1 file changed, 25 insertions(+), 73 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index a2b6a30918f6..75b402132e3f 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1502,6 +1502,7 @@ static void am65_cpsw_nuss_tx_wake(struct am65_cpsw_tx_chn *tx_chn, struct net_d
static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
int chn, unsigned int budget, bool *tdown)
{
+ bool single_port = AM65_CPSW_IS_CPSW2G(common);
enum am65_cpsw_tx_buf_type buf_type;
struct device *dev = common->dev;
struct am65_cpsw_tx_chn *tx_chn;
@@ -1509,6 +1510,7 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
unsigned int total_bytes = 0;
struct net_device *ndev;
struct xdp_frame *xdpf;
+ unsigned int pkt_len;
struct sk_buff *skb;
dma_addr_t desc_dma;
int res, num_tx = 0;
@@ -1516,9 +1518,12 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
tx_chn = &common->tx_chns[chn];
while (true) {
- spin_lock(&tx_chn->lock);
+ if (!single_port)
+ spin_lock(&tx_chn->lock);
res = k3_udma_glue_pop_tx_chn(tx_chn->tx_chn, &desc_dma);
- spin_unlock(&tx_chn->lock);
+ if (!single_port)
+ spin_unlock(&tx_chn->lock);
+
if (res == -ENODATA)
break;
@@ -1533,23 +1538,35 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
skb = am65_cpsw_nuss_tx_compl_packet_skb(tx_chn, desc_dma);
ndev = skb->dev;
- total_bytes = skb->len;
+ pkt_len = skb->len;
napi_consume_skb(skb, budget);
} else {
xdpf = am65_cpsw_nuss_tx_compl_packet_xdp(common, tx_chn,
desc_dma, &ndev);
- total_bytes = xdpf->len;
+ pkt_len = xdpf->len;
if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX)
xdp_return_frame_rx_napi(xdpf);
else
xdp_return_frame(xdpf);
}
+
+ total_bytes += pkt_len;
num_tx++;
- netif_txq = netdev_get_tx_queue(ndev, chn);
+ if (!single_port) {
+ /* as packets from multi ports can be interleaved
+ * on the same channel, we have to figure out the
+ * port/queue at every packet and report it/wake queue.
+ */
+ netif_txq = netdev_get_tx_queue(ndev, chn);
+ netdev_tx_completed_queue(netif_txq, 1, pkt_len);
+ am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
+ }
+ }
+ if (single_port) {
+ netif_txq = netdev_get_tx_queue(ndev, chn);
netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
-
am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
}
@@ -1558,66 +1575,6 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
return num_tx;
}
-static int am65_cpsw_nuss_tx_compl_packets_2g(struct am65_cpsw_common *common,
- int chn, unsigned int budget, bool *tdown)
-{
- enum am65_cpsw_tx_buf_type buf_type;
- struct device *dev = common->dev;
- struct am65_cpsw_tx_chn *tx_chn;
- struct netdev_queue *netif_txq;
- unsigned int total_bytes = 0;
- struct net_device *ndev;
- struct xdp_frame *xdpf;
- struct sk_buff *skb;
- dma_addr_t desc_dma;
- int res, num_tx = 0;
-
- tx_chn = &common->tx_chns[chn];
-
- while (true) {
- res = k3_udma_glue_pop_tx_chn(tx_chn->tx_chn, &desc_dma);
- if (res == -ENODATA)
- break;
-
- if (cppi5_desc_is_tdcm(desc_dma)) {
- if (atomic_dec_and_test(&common->tdown_cnt))
- complete(&common->tdown_complete);
- *tdown = true;
- break;
- }
-
- buf_type = am65_cpsw_nuss_buf_type(tx_chn, desc_dma);
- if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
- skb = am65_cpsw_nuss_tx_compl_packet_skb(tx_chn, desc_dma);
- ndev = skb->dev;
- total_bytes += skb->len;
- napi_consume_skb(skb, budget);
- } else {
- xdpf = am65_cpsw_nuss_tx_compl_packet_xdp(common, tx_chn,
- desc_dma, &ndev);
- total_bytes += xdpf->len;
- if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX)
- xdp_return_frame_rx_napi(xdpf);
- else
- xdp_return_frame(xdpf);
- }
- num_tx++;
- }
-
- if (!num_tx)
- return 0;
-
- netif_txq = netdev_get_tx_queue(ndev, chn);
-
- netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
-
- am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
-
- dev_dbg(dev, "%s:%u pkt:%d\n", __func__, chn, num_tx);
-
- return num_tx;
-}
-
static enum hrtimer_restart am65_cpsw_nuss_tx_timer_callback(struct hrtimer *timer)
{
struct am65_cpsw_tx_chn *tx_chns =
@@ -1633,13 +1590,8 @@ static int am65_cpsw_nuss_tx_poll(struct napi_struct *napi_tx, int budget)
bool tdown = false;
int num_tx;
- if (AM65_CPSW_IS_CPSW2G(tx_chn->common))
- num_tx = am65_cpsw_nuss_tx_compl_packets_2g(tx_chn->common, tx_chn->id,
- budget, &tdown);
- else
- num_tx = am65_cpsw_nuss_tx_compl_packets(tx_chn->common,
- tx_chn->id, budget, &tdown);
-
+ num_tx = am65_cpsw_nuss_tx_compl_packets(tx_chn->common,
+ tx_chn->id, budget, &tdown);
if (num_tx >= budget)
return budget;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
@ 2025-02-17 7:31 ` Roger Quadros
2025-02-18 18:01 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp() Roger Quadros
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
am65_cpsw_run_xdp() can figure out the cpu id itself.
No need to pass it around 2 functions so drop it.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 75b402132e3f..6bd4f526cb8e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1167,14 +1167,14 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
struct am65_cpsw_port *port,
- struct xdp_buff *xdp,
- int cpu, int *len)
+ struct xdp_buff *xdp, int *len)
{
struct am65_cpsw_common *common = flow->common;
struct net_device *ndev = port->ndev;
int ret = AM65_CPSW_XDP_CONSUMED;
struct am65_cpsw_tx_chn *tx_chn;
struct netdev_queue *netif_txq;
+ int cpu = smp_processor_id();
struct xdp_frame *xdpf;
struct bpf_prog *prog;
struct page *page;
@@ -1274,7 +1274,7 @@ static void am65_cpsw_nuss_rx_csum(struct sk_buff *skb, u32 csum_info)
}
static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow,
- int cpu, int *xdp_state)
+ int *xdp_state)
{
struct am65_cpsw_rx_chn *rx_chn = &flow->common->rx_chns;
u32 buf_dma_len, pkt_len, port_id = 0, csum_info;
@@ -1334,8 +1334,7 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow,
xdp_init_buff(&xdp, PAGE_SIZE, &port->xdp_rxq[flow->id]);
xdp_prepare_buff(&xdp, page_addr, AM65_CPSW_HEADROOM,
pkt_len, false);
- *xdp_state = am65_cpsw_run_xdp(flow, port, &xdp,
- cpu, &pkt_len);
+ *xdp_state = am65_cpsw_run_xdp(flow, port, &xdp, &pkt_len);
if (*xdp_state != AM65_CPSW_XDP_PASS)
goto allocate;
@@ -1399,7 +1398,6 @@ static int am65_cpsw_nuss_rx_poll(struct napi_struct *napi_rx, int budget)
{
struct am65_cpsw_rx_flow *flow = am65_cpsw_napi_to_rx_flow(napi_rx);
struct am65_cpsw_common *common = flow->common;
- int cpu = smp_processor_id();
int xdp_state_or = 0;
int cur_budget, ret;
int xdp_state;
@@ -1408,7 +1406,7 @@ static int am65_cpsw_nuss_rx_poll(struct napi_struct *napi_rx, int budget)
/* process only this flow */
cur_budget = budget;
while (cur_budget--) {
- ret = am65_cpsw_nuss_rx_packets(flow, cpu, &xdp_state);
+ ret = am65_cpsw_nuss_rx_packets(flow, &xdp_state);
xdp_state_or |= xdp_state;
if (ret)
break;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp()
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp Roger Quadros
@ 2025-02-17 7:31 ` Roger Quadros
2025-02-18 18:02 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp() Roger Quadros
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
In am65_cpsw_run_xdp() instead of goto followed by return, simply return.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 6bd4f526cb8e..468fddd0afd2 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1193,8 +1193,7 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
switch (act) {
case XDP_PASS:
- ret = AM65_CPSW_XDP_PASS;
- goto out;
+ return AM65_CPSW_XDP_PASS;
case XDP_TX:
tx_chn = &common->tx_chns[cpu % AM65_CPSW_MAX_QUEUES];
netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
@@ -1213,15 +1212,13 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
goto drop;
dev_sw_netstats_rx_add(ndev, pkt_len);
- ret = AM65_CPSW_XDP_CONSUMED;
- goto out;
+ return AM65_CPSW_XDP_CONSUMED;
case XDP_REDIRECT:
if (unlikely(xdp_do_redirect(ndev, xdp, prog)))
goto drop;
dev_sw_netstats_rx_add(ndev, pkt_len);
- ret = AM65_CPSW_XDP_REDIRECT;
- goto out;
+ return AM65_CPSW_XDP_REDIRECT;
default:
bpf_warn_invalid_xdp_action(ndev, prog, act);
fallthrough;
@@ -1236,7 +1233,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
page = virt_to_head_page(xdp->data);
am65_cpsw_put_page(flow, page, true);
-out:
return ret;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp()
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
` (2 preceding siblings ...)
2025-02-17 7:31 ` [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp() Roger Quadros
@ 2025-02-17 7:31 ` Roger Quadros
2025-02-18 18:03 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions Roger Quadros
2025-02-19 12:00 ` [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup patchwork-bot+netdevbpf
5 siblings, 1 reply; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
This allows us to re-use am65_cpsw_run_xdp() for zero copy
case. Add AM65_CPSW_XDP_TX case for successful XDP_TX so we don't
free the page while in flight.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 468fddd0afd2..32349cc58e2e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -164,6 +164,7 @@
#define AM65_CPSW_CPPI_TX_PKT_TYPE 0x7
/* XDP */
+#define AM65_CPSW_XDP_TX BIT(2)
#define AM65_CPSW_XDP_CONSUMED BIT(1)
#define AM65_CPSW_XDP_REDIRECT BIT(0)
#define AM65_CPSW_XDP_PASS 0
@@ -1177,7 +1178,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
int cpu = smp_processor_id();
struct xdp_frame *xdpf;
struct bpf_prog *prog;
- struct page *page;
int pkt_len;
u32 act;
int err;
@@ -1212,7 +1212,7 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
goto drop;
dev_sw_netstats_rx_add(ndev, pkt_len);
- return AM65_CPSW_XDP_CONSUMED;
+ return AM65_CPSW_XDP_TX;
case XDP_REDIRECT:
if (unlikely(xdp_do_redirect(ndev, xdp, prog)))
goto drop;
@@ -1230,9 +1230,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
ndev->stats.rx_dropped++;
}
- page = virt_to_head_page(xdp->data);
- am65_cpsw_put_page(flow, page, true);
-
return ret;
}
@@ -1331,6 +1328,12 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow,
xdp_prepare_buff(&xdp, page_addr, AM65_CPSW_HEADROOM,
pkt_len, false);
*xdp_state = am65_cpsw_run_xdp(flow, port, &xdp, &pkt_len);
+ if (*xdp_state == AM65_CPSW_XDP_CONSUMED) {
+ page = virt_to_head_page(xdp.data);
+ am65_cpsw_put_page(flow, page, true);
+ goto allocate;
+ }
+
if (*xdp_state != AM65_CPSW_XDP_PASS)
goto allocate;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
` (3 preceding siblings ...)
2025-02-17 7:31 ` [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp() Roger Quadros
@ 2025-02-17 7:31 ` Roger Quadros
2025-02-18 18:04 ` Simon Horman
2025-02-19 12:00 ` [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup patchwork-bot+netdevbpf
5 siblings, 1 reply; 13+ messages in thread
From: Roger Quadros @ 2025-02-17 7:31 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar
Cc: srk, netdev, linux-kernel, bpf, Roger Quadros
Drop separate TX completion functions for SKB and XDP. To do that
use the SW_DATA mechanism to store ndev and skb/xdpf for TX packets.
Use BUILD_BUG_ON_MSG() to fail build if SW_DATA size exceeds whats
available. i.e. AM65_CPSW_NAV_SW_DATA_SIZE.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 82 ++++++++++----------------------
drivers/net/ethernet/ti/am65-cpsw-nuss.h | 8 ++++
2 files changed, 32 insertions(+), 58 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 32349cc58e2e..213ec2cbe436 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -830,19 +830,19 @@ static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma)
{
struct am65_cpsw_tx_chn *tx_chn = data;
enum am65_cpsw_tx_buf_type buf_type;
+ struct am65_cpsw_tx_swdata *swdata;
struct cppi5_host_desc_t *desc_tx;
struct xdp_frame *xdpf;
struct sk_buff *skb;
- void **swdata;
desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, desc_dma);
swdata = cppi5_hdesc_get_swdata(desc_tx);
buf_type = am65_cpsw_nuss_buf_type(tx_chn, desc_dma);
if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
- skb = *(swdata);
+ skb = swdata->skb;
dev_kfree_skb_any(skb);
} else {
- xdpf = *(swdata);
+ xdpf = swdata->xdpf;
xdp_return_frame(xdpf);
}
@@ -1099,10 +1099,10 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
struct cppi5_host_desc_t *host_desc;
+ struct am65_cpsw_tx_swdata *swdata;
struct netdev_queue *netif_txq;
dma_addr_t dma_desc, dma_buf;
u32 pkt_len = xdpf->len;
- void **swdata;
int ret;
host_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool);
@@ -1132,7 +1132,8 @@ static int am65_cpsw_xdp_tx_frame(struct net_device *ndev,
cppi5_hdesc_attach_buf(host_desc, dma_buf, pkt_len, dma_buf, pkt_len);
swdata = cppi5_hdesc_get_swdata(host_desc);
- *(swdata) = xdpf;
+ swdata->ndev = ndev;
+ swdata->xdpf = xdpf;
/* Report BQL before sending the packet */
netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
@@ -1433,52 +1434,6 @@ static int am65_cpsw_nuss_rx_poll(struct napi_struct *napi_rx, int budget)
return num_rx;
}
-static struct sk_buff *
-am65_cpsw_nuss_tx_compl_packet_skb(struct am65_cpsw_tx_chn *tx_chn,
- dma_addr_t desc_dma)
-{
- struct cppi5_host_desc_t *desc_tx;
- struct sk_buff *skb;
- void **swdata;
-
- desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool,
- desc_dma);
- swdata = cppi5_hdesc_get_swdata(desc_tx);
- skb = *(swdata);
- am65_cpsw_nuss_xmit_free(tx_chn, desc_tx);
-
- am65_cpts_tx_timestamp(tx_chn->common->cpts, skb);
-
- dev_sw_netstats_tx_add(skb->dev, 1, skb->len);
-
- return skb;
-}
-
-static struct xdp_frame *
-am65_cpsw_nuss_tx_compl_packet_xdp(struct am65_cpsw_common *common,
- struct am65_cpsw_tx_chn *tx_chn,
- dma_addr_t desc_dma,
- struct net_device **ndev)
-{
- struct cppi5_host_desc_t *desc_tx;
- struct am65_cpsw_port *port;
- struct xdp_frame *xdpf;
- u32 port_id = 0;
- void **swdata;
-
- desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, desc_dma);
- cppi5_desc_get_tags_ids(&desc_tx->hdr, NULL, &port_id);
- swdata = cppi5_hdesc_get_swdata(desc_tx);
- xdpf = *(swdata);
- am65_cpsw_nuss_xmit_free(tx_chn, desc_tx);
-
- port = am65_common_get_port(common, port_id);
- dev_sw_netstats_tx_add(port->ndev, 1, xdpf->len);
- *ndev = port->ndev;
-
- return xdpf;
-}
-
static void am65_cpsw_nuss_tx_wake(struct am65_cpsw_tx_chn *tx_chn, struct net_device *ndev,
struct netdev_queue *netif_txq)
{
@@ -1501,6 +1456,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
{
bool single_port = AM65_CPSW_IS_CPSW2G(common);
enum am65_cpsw_tx_buf_type buf_type;
+ struct am65_cpsw_tx_swdata *swdata;
+ struct cppi5_host_desc_t *desc_tx;
struct device *dev = common->dev;
struct am65_cpsw_tx_chn *tx_chn;
struct netdev_queue *netif_txq;
@@ -1531,15 +1488,18 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
break;
}
+ desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool,
+ desc_dma);
+ swdata = cppi5_hdesc_get_swdata(desc_tx);
+ ndev = swdata->ndev;
buf_type = am65_cpsw_nuss_buf_type(tx_chn, desc_dma);
if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
- skb = am65_cpsw_nuss_tx_compl_packet_skb(tx_chn, desc_dma);
- ndev = skb->dev;
+ skb = swdata->skb;
+ am65_cpts_tx_timestamp(tx_chn->common->cpts, skb);
pkt_len = skb->len;
napi_consume_skb(skb, budget);
} else {
- xdpf = am65_cpsw_nuss_tx_compl_packet_xdp(common, tx_chn,
- desc_dma, &ndev);
+ xdpf = swdata->xdpf;
pkt_len = xdpf->len;
if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX)
xdp_return_frame_rx_napi(xdpf);
@@ -1549,7 +1509,8 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
total_bytes += pkt_len;
num_tx++;
-
+ am65_cpsw_nuss_xmit_free(tx_chn, desc_tx);
+ dev_sw_netstats_tx_add(ndev, 1, pkt_len);
if (!single_port) {
/* as packets from multi ports can be interleaved
* on the same channel, we have to figure out the
@@ -1632,12 +1593,12 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb,
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
struct cppi5_host_desc_t *first_desc, *next_desc, *cur_desc;
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+ struct am65_cpsw_tx_swdata *swdata;
struct device *dev = common->dev;
struct am65_cpsw_tx_chn *tx_chn;
struct netdev_queue *netif_txq;
dma_addr_t desc_dma, buf_dma;
int ret, q_idx, i;
- void **swdata;
u32 *psdata;
u32 pkt_len;
@@ -1683,7 +1644,8 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb,
k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &buf_dma);
cppi5_hdesc_attach_buf(first_desc, buf_dma, pkt_len, buf_dma, pkt_len);
swdata = cppi5_hdesc_get_swdata(first_desc);
- *(swdata) = skb;
+ swdata->ndev = ndev;
+ swdata->skb = skb;
psdata = cppi5_hdesc_get_psdata(first_desc);
/* HW csum offload if enabled */
@@ -3525,6 +3487,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
__be64 id_temp;
int ret, i;
+ BUILD_BUG_ON_MSG(sizeof(struct am65_cpsw_tx_swdata) > AM65_CPSW_NAV_SW_DATA_SIZE,
+ "TX SW_DATA size exceeds AM65_CPSW_NAV_SW_DATA_SIZE");
+ BUILD_BUG_ON_MSG(sizeof(struct am65_cpsw_swdata) > AM65_CPSW_NAV_SW_DATA_SIZE,
+ "SW_DATA size exceeds AM65_CPSW_NAV_SW_DATA_SIZE");
common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL);
if (!common)
return -ENOMEM;
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
index e7832a5cf3cc..917c37e4e89b 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
@@ -104,6 +104,14 @@ struct am65_cpsw_rx_flow {
char name[32];
};
+struct am65_cpsw_tx_swdata {
+ struct net_device *ndev;
+ union {
+ struct sk_buff *skb;
+ struct xdp_frame *xdpf;
+ };
+};
+
struct am65_cpsw_swdata {
u32 flow_id;
struct page *page;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()
2025-02-17 7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
@ 2025-02-18 18:01 ` Simon Horman
0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-18 18:01 UTC (permalink / raw)
To: Roger Quadros
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On Mon, Feb 17, 2025 at 09:31:46AM +0200, Roger Quadros wrote:
> The only difference between am65_cpsw_nuss_tx_compl_packets_2g() and
> am65_cpsw_nuss_tx_compl_packets() is the usage of spin_lock() and
> netdev_tx_completed_queue() + am65_cpsw_nuss_tx_wake at every packet
> in the latter.
>
> Insted of having 2 separate functions for TX completion, merge them
nit, in case there is a v2 for some other reason: Instead
> into one. This will reduce code duplication and make maintenance easier.
>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
...
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
...
> @@ -1533,23 +1538,35 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
> if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
> skb = am65_cpsw_nuss_tx_compl_packet_skb(tx_chn, desc_dma);
> ndev = skb->dev;
> - total_bytes = skb->len;
> + pkt_len = skb->len;
> napi_consume_skb(skb, budget);
> } else {
> xdpf = am65_cpsw_nuss_tx_compl_packet_xdp(common, tx_chn,
> desc_dma, &ndev);
> - total_bytes = xdpf->len;
> + pkt_len = xdpf->len;
> if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX)
> xdp_return_frame_rx_napi(xdpf);
> else
> xdp_return_frame(xdpf);
> }
> +
> + total_bytes += pkt_len;
> num_tx++;
>
> - netif_txq = netdev_get_tx_queue(ndev, chn);
> + if (!single_port) {
> + /* as packets from multi ports can be interleaved
> + * on the same channel, we have to figure out the
> + * port/queue at every packet and report it/wake queue.
> + */
> + netif_txq = netdev_get_tx_queue(ndev, chn);
> + netdev_tx_completed_queue(netif_txq, 1, pkt_len);
> + am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
> + }
> + }
>
> + if (single_port) {
> + netif_txq = netdev_get_tx_queue(ndev, chn);
> netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
> -
> am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
> }
Maybe it's not worth it, but it seems that a helper could
avoid duplication of the netif_txq handling immediately above (twice).
Regardless, this looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
...
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp
2025-02-17 7:31 ` [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp Roger Quadros
@ 2025-02-18 18:01 ` Simon Horman
0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-18 18:01 UTC (permalink / raw)
To: Roger Quadros
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On Mon, Feb 17, 2025 at 09:31:47AM +0200, Roger Quadros wrote:
> am65_cpsw_run_xdp() can figure out the cpu id itself.
> No need to pass it around 2 functions so drop it.
>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp()
2025-02-17 7:31 ` [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp() Roger Quadros
@ 2025-02-18 18:02 ` Simon Horman
0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-18 18:02 UTC (permalink / raw)
To: Roger Quadros
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On Mon, Feb 17, 2025 at 09:31:48AM +0200, Roger Quadros wrote:
> In am65_cpsw_run_xdp() instead of goto followed by return, simply return.
>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp()
2025-02-17 7:31 ` [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp() Roger Quadros
@ 2025-02-18 18:03 ` Simon Horman
2025-02-24 13:00 ` Roger Quadros
0 siblings, 1 reply; 13+ messages in thread
From: Simon Horman @ 2025-02-18 18:03 UTC (permalink / raw)
To: Roger Quadros
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On Mon, Feb 17, 2025 at 09:31:49AM +0200, Roger Quadros wrote:
> This allows us to re-use am65_cpsw_run_xdp() for zero copy
> case. Add AM65_CPSW_XDP_TX case for successful XDP_TX so we don't
> free the page while in flight.
>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
...
> @@ -1230,9 +1230,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
> ndev->stats.rx_dropped++;
> }
>
> - page = virt_to_head_page(xdp->data);
> - am65_cpsw_put_page(flow, page, true);
> -
> return ret;
It seems that before and after this patch ret is always initialised to
AM65_CPSW_XDP_CONSUMED and never changed. So it can be removed.
Given that with this patch the function only returns after the switch
statement, I think this would be a nice follow-up.
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 20a4fc3e579f..4052c9153632 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1172,7 +1172,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
{
struct am65_cpsw_common *common = flow->common;
struct net_device *ndev = port->ndev;
- int ret = AM65_CPSW_XDP_CONSUMED;
struct am65_cpsw_tx_chn *tx_chn;
struct netdev_queue *netif_txq;
int cpu = smp_processor_id();
@@ -1228,9 +1227,8 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
fallthrough;
case XDP_DROP:
ndev->stats.rx_dropped++;
+ return AM65_CPSW_XDP_CONSUMED;
}
-
- return ret;
}
/* RX psdata[2] word format - checksum information */
...
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions
2025-02-17 7:31 ` [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions Roger Quadros
@ 2025-02-18 18:04 ` Simon Horman
0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-18 18:04 UTC (permalink / raw)
To: Roger Quadros
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On Mon, Feb 17, 2025 at 09:31:50AM +0200, Roger Quadros wrote:
> Drop separate TX completion functions for SKB and XDP. To do that
> use the SW_DATA mechanism to store ndev and skb/xdpf for TX packets.
>
> Use BUILD_BUG_ON_MSG() to fail build if SW_DATA size exceeds whats
> available. i.e. AM65_CPSW_NAV_SW_DATA_SIZE.
>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
` (4 preceding siblings ...)
2025-02-17 7:31 ` [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions Roger Quadros
@ 2025-02-19 12:00 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-19 12:00 UTC (permalink / raw)
To: Roger Quadros
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, ast, daniel, hawk,
john.fastabend, s-vadapalli, danishanwar, srk, netdev,
linux-kernel, bpf
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 17 Feb 2025 09:31:45 +0200 you wrote:
> We have 2 tx completion functions to handle single-port vs multi-port
> variants. Merge them into one function to make maintenance easier.
>
> We also have 2 functions to handle TX completion for SKB vs XDP.
> Get rid of them too.
>
> Also do some minor cleanups.
>
> [...]
Here is the summary with links:
- [net-next,1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()
https://git.kernel.org/netdev/net-next/c/9a369ae3d143
- [net-next,2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp
https://git.kernel.org/netdev/net-next/c/1ae26bf61517
- [net-next,3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp()
https://git.kernel.org/netdev/net-next/c/09057ce3774e
- [net-next,4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp()
https://git.kernel.org/netdev/net-next/c/6d6c7933cea6
- [net-next,5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions
https://git.kernel.org/netdev/net-next/c/ce643fa62a70
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp()
2025-02-18 18:03 ` Simon Horman
@ 2025-02-24 13:00 ` Roger Quadros
0 siblings, 0 replies; 13+ messages in thread
From: Roger Quadros @ 2025-02-24 13:00 UTC (permalink / raw)
To: Simon Horman
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Siddharth Vadapalli,
Md Danish Anwar, srk, netdev, linux-kernel, bpf
On 18/02/2025 20:03, Simon Horman wrote:
> On Mon, Feb 17, 2025 at 09:31:49AM +0200, Roger Quadros wrote:
>> This allows us to re-use am65_cpsw_run_xdp() for zero copy
>> case. Add AM65_CPSW_XDP_TX case for successful XDP_TX so we don't
>> free the page while in flight.
>>
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
>> ---
>> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 ++++++++-----
>> 1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>
> ...
>
>> @@ -1230,9 +1230,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
>> ndev->stats.rx_dropped++;
>> }
>>
>> - page = virt_to_head_page(xdp->data);
>> - am65_cpsw_put_page(flow, page, true);
>> -
>> return ret;
>
> It seems that before and after this patch ret is always initialised to
> AM65_CPSW_XDP_CONSUMED and never changed. So it can be removed.
>
> Given that with this patch the function only returns after the switch
> statement, I think this would be a nice follow-up.
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 20a4fc3e579f..4052c9153632 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -1172,7 +1172,6 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
> {
> struct am65_cpsw_common *common = flow->common;
> struct net_device *ndev = port->ndev;
> - int ret = AM65_CPSW_XDP_CONSUMED;
> struct am65_cpsw_tx_chn *tx_chn;
> struct netdev_queue *netif_txq;
> int cpu = smp_processor_id();
> @@ -1228,9 +1227,8 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow,
> fallthrough;
> case XDP_DROP:
> ndev->stats.rx_dropped++;
> + return AM65_CPSW_XDP_CONSUMED;
> }
> -
> - return ret;
> }
>
> /* RX psdata[2] word format - checksum information */
>
> ...
Thank you for this suggestion. I will add this cleanup in my next set of patches.
--
cheers,
-roger
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-02-24 13:00 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
2025-02-18 18:01 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp Roger Quadros
2025-02-18 18:01 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp() Roger Quadros
2025-02-18 18:02 ` Simon Horman
2025-02-17 7:31 ` [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp() Roger Quadros
2025-02-18 18:03 ` Simon Horman
2025-02-24 13:00 ` Roger Quadros
2025-02-17 7:31 ` [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions Roger Quadros
2025-02-18 18:04 ` Simon Horman
2025-02-19 12:00 ` [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).