Commit e3fdf6ba authored by Ioana Radulescu's avatar Ioana Radulescu Committed by David S. Miller

dpaa2-eth: Add software annotation types

We write different metadata information in the software annotation
area of Tx frames, depending on frame type. Make this more explicit
by introducing a type field and separate structures for single buffer
and scatter-gather frames.
Signed-off-by: default avatarIoana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cec12ce
...@@ -571,10 +571,11 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv, ...@@ -571,10 +571,11 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
* all of them on Tx Conf. * all of them on Tx Conf.
*/ */
swa = (struct dpaa2_eth_swa *)sgt_buf; swa = (struct dpaa2_eth_swa *)sgt_buf;
swa->skb = skb; swa->type = DPAA2_ETH_SWA_SG;
swa->scl = scl; swa->sg.skb = skb;
swa->num_sg = num_sg; swa->sg.scl = scl;
swa->sgt_size = sgt_buf_size; swa->sg.num_sg = num_sg;
swa->sg.sgt_size = sgt_buf_size;
/* Separately map the SGT buffer */ /* Separately map the SGT buffer */
addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL); addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL);
...@@ -609,7 +610,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, ...@@ -609,7 +610,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
{ {
struct device *dev = priv->net_dev->dev.parent; struct device *dev = priv->net_dev->dev.parent;
u8 *buffer_start, *aligned_start; u8 *buffer_start, *aligned_start;
struct sk_buff **skbh; struct dpaa2_eth_swa *swa;
dma_addr_t addr; dma_addr_t addr;
buffer_start = skb->data - dpaa2_eth_needed_headroom(priv, skb); buffer_start = skb->data - dpaa2_eth_needed_headroom(priv, skb);
...@@ -626,8 +627,9 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, ...@@ -626,8 +627,9 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
* (in the private data area) such that we can release it * (in the private data area) such that we can release it
* on Tx confirm * on Tx confirm
*/ */
skbh = (struct sk_buff **)buffer_start; swa = (struct dpaa2_eth_swa *)buffer_start;
*skbh = skb; swa->type = DPAA2_ETH_SWA_SINGLE;
swa->single.skb = skb;
addr = dma_map_single(dev, buffer_start, addr = dma_map_single(dev, buffer_start,
skb_tail_pointer(skb) - buffer_start, skb_tail_pointer(skb) - buffer_start,
...@@ -659,17 +661,17 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, ...@@ -659,17 +661,17 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
{ {
struct device *dev = priv->net_dev->dev.parent; struct device *dev = priv->net_dev->dev.parent;
dma_addr_t fd_addr; dma_addr_t fd_addr;
struct sk_buff **skbh, *skb; struct sk_buff *skb;
unsigned char *buffer_start; unsigned char *buffer_start;
struct dpaa2_eth_swa *swa; struct dpaa2_eth_swa *swa;
u8 fd_format = dpaa2_fd_get_format(fd); u8 fd_format = dpaa2_fd_get_format(fd);
fd_addr = dpaa2_fd_get_addr(fd); fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr); buffer_start = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
swa = (struct dpaa2_eth_swa *)buffer_start;
if (fd_format == dpaa2_fd_single) { if (fd_format == dpaa2_fd_single) {
skb = *skbh; skb = swa->single.skb;
buffer_start = (unsigned char *)skbh;
/* Accessing the skb buffer is safe before dma unmap, because /* Accessing the skb buffer is safe before dma unmap, because
* we didn't map the actual skb shell. * we didn't map the actual skb shell.
*/ */
...@@ -677,15 +679,15 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, ...@@ -677,15 +679,15 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
skb_tail_pointer(skb) - buffer_start, skb_tail_pointer(skb) - buffer_start,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
} else if (fd_format == dpaa2_fd_sg) { } else if (fd_format == dpaa2_fd_sg) {
swa = (struct dpaa2_eth_swa *)skbh; skb = swa->sg.skb;
skb = swa->skb;
/* Unmap the scatterlist */ /* Unmap the scatterlist */
dma_unmap_sg(dev, swa->scl, swa->num_sg, DMA_BIDIRECTIONAL); dma_unmap_sg(dev, swa->sg.scl, swa->sg.num_sg,
kfree(swa->scl); DMA_BIDIRECTIONAL);
kfree(swa->sg.scl);
/* Unmap the SGT buffer */ /* Unmap the SGT buffer */
dma_unmap_single(dev, fd_addr, swa->sgt_size, dma_unmap_single(dev, fd_addr, swa->sg.sgt_size,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
} else { } else {
netdev_dbg(priv->net_dev, "Invalid FD format\n"); netdev_dbg(priv->net_dev, "Invalid FD format\n");
...@@ -695,7 +697,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, ...@@ -695,7 +697,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
/* Get the timestamp value */ /* Get the timestamp value */
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
struct skb_shared_hwtstamps shhwtstamps; struct skb_shared_hwtstamps shhwtstamps;
__le64 *ts = dpaa2_get_ts(skbh, true); __le64 *ts = dpaa2_get_ts(buffer_start, true);
u64 ns; u64 ns;
memset(&shhwtstamps, 0, sizeof(shhwtstamps)); memset(&shhwtstamps, 0, sizeof(shhwtstamps));
...@@ -707,7 +709,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, ...@@ -707,7 +709,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
/* Free SGT buffer allocated on tx */ /* Free SGT buffer allocated on tx */
if (fd_format != dpaa2_fd_single) if (fd_format != dpaa2_fd_single)
skb_free_frag(skbh); skb_free_frag(buffer_start);
/* Move on with skb release */ /* Move on with skb release */
napi_consume_skb(skb, in_napi); napi_consume_skb(skb, in_napi);
......
...@@ -89,12 +89,28 @@ ...@@ -89,12 +89,28 @@
*/ */
#define DPAA2_ETH_SWA_SIZE 64 #define DPAA2_ETH_SWA_SIZE 64
/* We store different information in the software annotation area of a Tx frame
* based on what type of frame it is
*/
enum dpaa2_eth_swa_type {
DPAA2_ETH_SWA_SINGLE,
DPAA2_ETH_SWA_SG,
};
/* Must keep this struct smaller than DPAA2_ETH_SWA_SIZE */ /* Must keep this struct smaller than DPAA2_ETH_SWA_SIZE */
struct dpaa2_eth_swa { struct dpaa2_eth_swa {
struct sk_buff *skb; enum dpaa2_eth_swa_type type;
struct scatterlist *scl; union {
int num_sg; struct {
int sgt_size; struct sk_buff *skb;
} single;
struct {
struct sk_buff *skb;
struct scatterlist *scl;
int num_sg;
int sgt_size;
} sg;
};
}; };
/* Annotation valid bits in FD FRC */ /* Annotation valid bits in FD FRC */
......
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