Commit 64a965de authored by Yangbo Lu's avatar Yangbo Lu Committed by David S. Miller

dpaa2-eth: invoke dpaa2_eth_enable_tx_tstamp() once in code

Invoke dpaa2_eth_enable_tx_tstamp() once in code after building FD,
rather than calling it in dpaa2_eth_build_single_fd(),
dpaa2_eth_build_sg_fd_single_buf(), and dpaa2_eth_build_sg_fd().
Signed-off-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d21c784c
...@@ -589,7 +589,8 @@ static void dpaa2_eth_enable_tx_tstamp(struct dpaa2_fd *fd, void *buf_start) ...@@ -589,7 +589,8 @@ static void dpaa2_eth_enable_tx_tstamp(struct dpaa2_fd *fd, void *buf_start)
/* Create a frame descriptor based on a fragmented skb */ /* Create a frame descriptor based on a fragmented skb */
static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv,
struct sk_buff *skb, struct sk_buff *skb,
struct dpaa2_fd *fd) struct dpaa2_fd *fd,
void **swa_addr)
{ {
struct device *dev = priv->net_dev->dev.parent; struct device *dev = priv->net_dev->dev.parent;
void *sgt_buf = NULL; void *sgt_buf = NULL;
...@@ -658,6 +659,7 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, ...@@ -658,6 +659,7 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv,
* skb backpointer in the software annotation area. We'll need * skb backpointer in the software annotation area. We'll need
* all of them on Tx Conf. * all of them on Tx Conf.
*/ */
*swa_addr = (void *)sgt_buf;
swa = (struct dpaa2_eth_swa *)sgt_buf; swa = (struct dpaa2_eth_swa *)sgt_buf;
swa->type = DPAA2_ETH_SWA_SG; swa->type = DPAA2_ETH_SWA_SG;
swa->sg.skb = skb; swa->sg.skb = skb;
...@@ -677,9 +679,6 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, ...@@ -677,9 +679,6 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_len(fd, skb->len); dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA); dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA);
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
dpaa2_eth_enable_tx_tstamp(fd, sgt_buf);
return 0; return 0;
dma_map_single_failed: dma_map_single_failed:
...@@ -699,7 +698,8 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, ...@@ -699,7 +698,8 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv,
*/ */
static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv,
struct sk_buff *skb, struct sk_buff *skb,
struct dpaa2_fd *fd) struct dpaa2_fd *fd,
void **swa_addr)
{ {
struct device *dev = priv->net_dev->dev.parent; struct device *dev = priv->net_dev->dev.parent;
struct dpaa2_eth_sgt_cache *sgt_cache; struct dpaa2_eth_sgt_cache *sgt_cache;
...@@ -737,6 +737,7 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, ...@@ -737,6 +737,7 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv,
dpaa2_sg_set_final(sgt, true); dpaa2_sg_set_final(sgt, true);
/* Store the skb backpointer in the SGT buffer */ /* Store the skb backpointer in the SGT buffer */
*swa_addr = (void *)sgt_buf;
swa = (struct dpaa2_eth_swa *)sgt_buf; swa = (struct dpaa2_eth_swa *)sgt_buf;
swa->type = DPAA2_ETH_SWA_SINGLE; swa->type = DPAA2_ETH_SWA_SINGLE;
swa->single.skb = skb; swa->single.skb = skb;
...@@ -755,9 +756,6 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, ...@@ -755,9 +756,6 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_len(fd, skb->len); dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA); dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA);
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
dpaa2_eth_enable_tx_tstamp(fd, sgt_buf);
return 0; return 0;
sgt_map_failed: sgt_map_failed:
...@@ -774,7 +772,8 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, ...@@ -774,7 +772,8 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv,
/* Create a frame descriptor based on a linear skb */ /* Create a frame descriptor based on a linear skb */
static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff *skb, struct sk_buff *skb,
struct dpaa2_fd *fd) struct dpaa2_fd *fd,
void **swa_addr)
{ {
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;
...@@ -795,6 +794,7 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, ...@@ -795,6 +794,7 @@ static int dpaa2_eth_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
*/ */
*swa_addr = (void *)buffer_start;
swa = (struct dpaa2_eth_swa *)buffer_start; swa = (struct dpaa2_eth_swa *)buffer_start;
swa->type = DPAA2_ETH_SWA_SINGLE; swa->type = DPAA2_ETH_SWA_SINGLE;
swa->single.skb = skb; swa->single.skb = skb;
...@@ -811,9 +811,6 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, ...@@ -811,9 +811,6 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_format(fd, dpaa2_fd_single); dpaa2_fd_set_format(fd, dpaa2_fd_single);
dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA); dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA);
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
dpaa2_eth_enable_tx_tstamp(fd, buffer_start);
return 0; return 0;
} }
...@@ -939,6 +936,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) ...@@ -939,6 +936,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
u32 fd_len; u32 fd_len;
u8 prio = 0; u8 prio = 0;
int err, i; int err, i;
void *swa;
percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras); percpu_extras = this_cpu_ptr(priv->percpu_extras);
...@@ -959,17 +957,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) ...@@ -959,17 +957,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
memset(&fd, 0, sizeof(fd)); memset(&fd, 0, sizeof(fd));
if (skb_is_nonlinear(skb)) { if (skb_is_nonlinear(skb)) {
err = dpaa2_eth_build_sg_fd(priv, skb, &fd); err = dpaa2_eth_build_sg_fd(priv, skb, &fd, &swa);
percpu_extras->tx_sg_frames++; percpu_extras->tx_sg_frames++;
percpu_extras->tx_sg_bytes += skb->len; percpu_extras->tx_sg_bytes += skb->len;
} else if (skb_headroom(skb) < needed_headroom) { } else if (skb_headroom(skb) < needed_headroom) {
err = dpaa2_eth_build_sg_fd_single_buf(priv, skb, &fd); err = dpaa2_eth_build_sg_fd_single_buf(priv, skb, &fd, &swa);
percpu_extras->tx_sg_frames++; percpu_extras->tx_sg_frames++;
percpu_extras->tx_sg_bytes += skb->len; percpu_extras->tx_sg_bytes += skb->len;
percpu_extras->tx_converted_sg_frames++; percpu_extras->tx_converted_sg_frames++;
percpu_extras->tx_converted_sg_bytes += skb->len; percpu_extras->tx_converted_sg_bytes += skb->len;
} else { } else {
err = dpaa2_eth_build_single_fd(priv, skb, &fd); err = dpaa2_eth_build_single_fd(priv, skb, &fd, &swa);
} }
if (unlikely(err)) { if (unlikely(err)) {
...@@ -977,6 +975,9 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) ...@@ -977,6 +975,9 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
goto err_build_fd; goto err_build_fd;
} }
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
dpaa2_eth_enable_tx_tstamp(&fd, swa);
/* Tracing point */ /* Tracing point */
trace_dpaa2_tx_fd(net_dev, &fd); trace_dpaa2_tx_fd(net_dev, &fd);
......
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