Commit aff0824d authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by David S. Miller

net: marvell: return csum computation result from mvneta_rx_csum/mvpp2_rx_csum

This is a preliminary patch to add hw csum hint support to
mvneta/mvpp2 xdp implementation
Tested-by: default avatarMatteo Croce <mcroce@linux.microsoft.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f84974e7
...@@ -1805,18 +1805,14 @@ static void mvneta_rx_error(struct mvneta_port *pp, ...@@ -1805,18 +1805,14 @@ static void mvneta_rx_error(struct mvneta_port *pp,
} }
/* Handle RX checksum offload based on the descriptor's status */ /* Handle RX checksum offload based on the descriptor's status */
static void mvneta_rx_csum(struct mvneta_port *pp, u32 status, static int mvneta_rx_csum(struct mvneta_port *pp, u32 status)
struct sk_buff *skb)
{ {
if ((pp->dev->features & NETIF_F_RXCSUM) && if ((pp->dev->features & NETIF_F_RXCSUM) &&
(status & MVNETA_RXD_L3_IP4) && (status & MVNETA_RXD_L3_IP4) &&
(status & MVNETA_RXD_L4_CSUM_OK)) { (status & MVNETA_RXD_L4_CSUM_OK))
skb->csum = 0; return CHECKSUM_UNNECESSARY;
skb->ip_summed = CHECKSUM_UNNECESSARY;
return;
}
skb->ip_summed = CHECKSUM_NONE; return CHECKSUM_NONE;
} }
/* Return tx queue pointer (find last set bit) according to <cause> returned /* Return tx queue pointer (find last set bit) according to <cause> returned
...@@ -2335,7 +2331,7 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool, ...@@ -2335,7 +2331,7 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool,
skb_reserve(skb, xdp->data - xdp->data_hard_start); skb_reserve(skb, xdp->data - xdp->data_hard_start);
skb_put(skb, xdp->data_end - xdp->data); skb_put(skb, xdp->data_end - xdp->data);
mvneta_rx_csum(pp, desc_status, skb); skb->ip_summed = mvneta_rx_csum(pp, desc_status);
for (i = 0; i < num_frags; i++) { for (i = 0; i < num_frags; i++) {
skb_frag_t *frag = &sinfo->frags[i]; skb_frag_t *frag = &sinfo->frags[i];
...@@ -2535,7 +2531,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi, ...@@ -2535,7 +2531,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi,
rx_bytes); rx_bytes);
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
mvneta_rx_csum(pp, rx_status, skb); skb->ip_summed = mvneta_rx_csum(pp, rx_status);
napi_gro_receive(napi, skb); napi_gro_receive(napi, skb);
rcvd_pkts++; rcvd_pkts++;
...@@ -2584,8 +2580,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi, ...@@ -2584,8 +2580,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi,
skb_put(skb, rx_bytes); skb_put(skb, rx_bytes);
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = mvneta_rx_csum(pp, rx_status);
mvneta_rx_csum(pp, rx_status, skb);
napi_gro_receive(napi, skb); napi_gro_receive(napi, skb);
} }
......
...@@ -3543,21 +3543,17 @@ static void mvpp2_rx_error(struct mvpp2_port *port, ...@@ -3543,21 +3543,17 @@ static void mvpp2_rx_error(struct mvpp2_port *port,
} }
/* Handle RX checksum offload */ /* Handle RX checksum offload */
static void mvpp2_rx_csum(struct mvpp2_port *port, u32 status, static int mvpp2_rx_csum(struct mvpp2_port *port, u32 status)
struct sk_buff *skb)
{ {
if (((status & MVPP2_RXD_L3_IP4) && if (((status & MVPP2_RXD_L3_IP4) &&
!(status & MVPP2_RXD_IP4_HEADER_ERR)) || !(status & MVPP2_RXD_IP4_HEADER_ERR)) ||
(status & MVPP2_RXD_L3_IP6)) (status & MVPP2_RXD_L3_IP6))
if (((status & MVPP2_RXD_L4_UDP) || if (((status & MVPP2_RXD_L4_UDP) ||
(status & MVPP2_RXD_L4_TCP)) && (status & MVPP2_RXD_L4_TCP)) &&
(status & MVPP2_RXD_L4_CSUM_OK)) { (status & MVPP2_RXD_L4_CSUM_OK))
skb->csum = 0; return CHECKSUM_UNNECESSARY;
skb->ip_summed = CHECKSUM_UNNECESSARY;
return;
}
skb->ip_summed = CHECKSUM_NONE; return CHECKSUM_NONE;
} }
/* Allocate a new skb and add it to BM pool */ /* Allocate a new skb and add it to BM pool */
...@@ -4012,7 +4008,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi, ...@@ -4012,7 +4008,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
skb_reserve(skb, MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM); skb_reserve(skb, MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM);
skb_put(skb, rx_bytes); skb_put(skb, rx_bytes);
mvpp2_rx_csum(port, rx_status, skb); skb->ip_summed = mvpp2_rx_csum(port, rx_status);
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
napi_gro_receive(napi, skb); napi_gro_receive(napi, skb);
......
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