net: dpaa2-eth: create and export the dpaa2_eth_alloc_skb function
authorRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Tue, 18 Oct 2022 14:18:57 +0000 (17:18 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Oct 2022 08:22:11 +0000 (09:22 +0100)
The dpaa2_eth_alloc_skb() function is added by moving code from the
dpaa2_eth_copybreak() previously defined function. What the new API does
is to allocate a new skb, copy the frame data from the passed FD to the
new skb and then return the skb.
Export this new function since we'll need the this functionality also
from the XSK code path.

Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h

index b95e9a7..9909fdf 100644 (file)
@@ -485,19 +485,15 @@ out:
        return xdp_act;
 }
 
-static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch,
-                                          const struct dpaa2_fd *fd,
-                                          void *fd_vaddr)
+struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv,
+                                   struct dpaa2_eth_channel *ch,
+                                   const struct dpaa2_fd *fd, u32 fd_length,
+                                   void *fd_vaddr)
 {
        u16 fd_offset = dpaa2_fd_get_offset(fd);
-       struct dpaa2_eth_priv *priv = ch->priv;
-       u32 fd_length = dpaa2_fd_get_len(fd);
        struct sk_buff *skb = NULL;
        unsigned int skb_len;
 
-       if (fd_length > priv->rx_copybreak)
-               return NULL;
-
        skb_len = fd_length + dpaa2_eth_needed_headroom(NULL);
 
        skb = napi_alloc_skb(&ch->napi, skb_len);
@@ -514,6 +510,19 @@ static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch,
        return skb;
 }
 
+static struct sk_buff *dpaa2_eth_copybreak(struct dpaa2_eth_channel *ch,
+                                          const struct dpaa2_fd *fd,
+                                          void *fd_vaddr)
+{
+       struct dpaa2_eth_priv *priv = ch->priv;
+       u32 fd_length = dpaa2_fd_get_len(fd);
+
+       if (fd_length > priv->rx_copybreak)
+               return NULL;
+
+       return dpaa2_eth_alloc_skb(priv, ch, fd, fd_length, fd_vaddr);
+}
+
 /* Main Rx frame processing routine */
 static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
                         struct dpaa2_eth_channel *ch,
index bb0881e..7c46ec3 100644 (file)
@@ -791,4 +791,9 @@ struct dpaa2_eth_trap_item *dpaa2_eth_dl_get_trap(struct dpaa2_eth_priv *priv,
 
 struct dpaa2_eth_bp *dpaa2_eth_allocate_dpbp(struct dpaa2_eth_priv *priv);
 void dpaa2_eth_free_dpbp(struct dpaa2_eth_priv *priv, struct dpaa2_eth_bp *bp);
+
+struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv,
+                                   struct dpaa2_eth_channel *ch,
+                                   const struct dpaa2_fd *fd, u32 fd_length,
+                                   void *fd_vaddr);
 #endif /* __DPAA2_H */