* [PATCH 1/2] net: netsec: remove superfluous if statement
@ 2019-07-09 21:14 Ilias Apalodimas
2019-07-09 21:14 ` [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de() Ilias Apalodimas
2019-07-09 21:46 ` [PATCH 1/2] net: netsec: remove superfluous if statement David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Ilias Apalodimas @ 2019-07-09 21:14 UTC (permalink / raw)
To: netdev, jaswinder.singh, davem; +Cc: Ilias Apalodimas
While freeing tx buffers the memory has to be unmapped if the packet was
an skb or was used for .ndo_xdp_xmit using the same arguments. Get rid
of the unneeded extra 'else if' statement
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
drivers/net/ethernet/socionext/netsec.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index c3a4f86f56ee..7f9280f1fb28 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -654,12 +654,12 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
eop = (entry->attr >> NETSEC_TX_LAST) & 1;
dma_rmb();
- if (desc->buf_type == TYPE_NETSEC_SKB)
+ /* if buf_type is either TYPE_NETSEC_SKB or
+ * TYPE_NETSEC_XDP_NDO we mapped it
+ */
+ if (desc->buf_type != TYPE_NETSEC_XDP_TX)
dma_unmap_single(priv->dev, desc->dma_addr, desc->len,
DMA_TO_DEVICE);
- else if (desc->buf_type == TYPE_NETSEC_XDP_NDO)
- dma_unmap_single(priv->dev, desc->dma_addr,
- desc->len, DMA_TO_DEVICE);
if (!eop)
goto next;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de()
2019-07-09 21:14 [PATCH 1/2] net: netsec: remove superfluous if statement Ilias Apalodimas
@ 2019-07-09 21:14 ` Ilias Apalodimas
2019-07-09 21:47 ` David Miller
2019-07-09 21:46 ` [PATCH 1/2] net: netsec: remove superfluous if statement David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-07-09 21:14 UTC (permalink / raw)
To: netdev, jaswinder.singh, davem; +Cc: Ilias Apalodimas
On commit ba2b232108d3 ("net: netsec: add XDP support") a static
declaration for netsec_set_tx_de() was added to make the diff easier
to read. Now that the patch is merged let's move the functions around
and get rid of that
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
drivers/net/ethernet/socionext/netsec.c | 86 ++++++++++++-------------
1 file changed, 41 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 7f9280f1fb28..1502fe8b0456 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -328,11 +328,6 @@ struct netsec_rx_pkt_info {
bool err_flag;
};
-static void netsec_set_tx_de(struct netsec_priv *priv,
- struct netsec_desc_ring *dring,
- const struct netsec_tx_pkt_ctrl *tx_ctrl,
- const struct netsec_desc *desc, void *buf);
-
static void netsec_write(struct netsec_priv *priv, u32 reg_addr, u32 val)
{
writel(val, priv->ioaddr + reg_addr);
@@ -778,6 +773,47 @@ static void netsec_finalize_xdp_rx(struct netsec_priv *priv, u32 xdp_res,
netsec_xdp_ring_tx_db(priv, pkts);
}
+static void netsec_set_tx_de(struct netsec_priv *priv,
+ struct netsec_desc_ring *dring,
+ const struct netsec_tx_pkt_ctrl *tx_ctrl,
+ const struct netsec_desc *desc, void *buf)
+{
+ int idx = dring->head;
+ struct netsec_de *de;
+ u32 attr;
+
+ de = dring->vaddr + (DESC_SZ * idx);
+
+ attr = (1 << NETSEC_TX_SHIFT_OWN_FIELD) |
+ (1 << NETSEC_TX_SHIFT_PT_FIELD) |
+ (NETSEC_RING_GMAC << NETSEC_TX_SHIFT_TDRID_FIELD) |
+ (1 << NETSEC_TX_SHIFT_FS_FIELD) |
+ (1 << NETSEC_TX_LAST) |
+ (tx_ctrl->cksum_offload_flag << NETSEC_TX_SHIFT_CO) |
+ (tx_ctrl->tcp_seg_offload_flag << NETSEC_TX_SHIFT_SO) |
+ (1 << NETSEC_TX_SHIFT_TRS_FIELD);
+ if (idx == DESC_NUM - 1)
+ attr |= (1 << NETSEC_TX_SHIFT_LD_FIELD);
+
+ de->data_buf_addr_up = upper_32_bits(desc->dma_addr);
+ de->data_buf_addr_lw = lower_32_bits(desc->dma_addr);
+ de->buf_len_info = (tx_ctrl->tcp_seg_len << 16) | desc->len;
+ de->attr = attr;
+ /* under spin_lock if using XDP */
+ if (!dring->is_xdp)
+ dma_wmb();
+
+ dring->desc[idx] = *desc;
+ if (desc->buf_type == TYPE_NETSEC_SKB)
+ dring->desc[idx].skb = buf;
+ else if (desc->buf_type == TYPE_NETSEC_XDP_TX ||
+ desc->buf_type == TYPE_NETSEC_XDP_NDO)
+ dring->desc[idx].xdpf = buf;
+
+ /* move head ahead */
+ dring->head = (dring->head + 1) % DESC_NUM;
+}
+
/* The current driver only supports 1 Txq, this should run under spin_lock() */
static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
struct xdp_frame *xdpf, bool is_ndo)
@@ -1041,46 +1077,6 @@ static int netsec_napi_poll(struct napi_struct *napi, int budget)
return done;
}
-static void netsec_set_tx_de(struct netsec_priv *priv,
- struct netsec_desc_ring *dring,
- const struct netsec_tx_pkt_ctrl *tx_ctrl,
- const struct netsec_desc *desc, void *buf)
-{
- int idx = dring->head;
- struct netsec_de *de;
- u32 attr;
-
- de = dring->vaddr + (DESC_SZ * idx);
-
- attr = (1 << NETSEC_TX_SHIFT_OWN_FIELD) |
- (1 << NETSEC_TX_SHIFT_PT_FIELD) |
- (NETSEC_RING_GMAC << NETSEC_TX_SHIFT_TDRID_FIELD) |
- (1 << NETSEC_TX_SHIFT_FS_FIELD) |
- (1 << NETSEC_TX_LAST) |
- (tx_ctrl->cksum_offload_flag << NETSEC_TX_SHIFT_CO) |
- (tx_ctrl->tcp_seg_offload_flag << NETSEC_TX_SHIFT_SO) |
- (1 << NETSEC_TX_SHIFT_TRS_FIELD);
- if (idx == DESC_NUM - 1)
- attr |= (1 << NETSEC_TX_SHIFT_LD_FIELD);
-
- de->data_buf_addr_up = upper_32_bits(desc->dma_addr);
- de->data_buf_addr_lw = lower_32_bits(desc->dma_addr);
- de->buf_len_info = (tx_ctrl->tcp_seg_len << 16) | desc->len;
- de->attr = attr;
- /* under spin_lock if using XDP */
- if (!dring->is_xdp)
- dma_wmb();
-
- dring->desc[idx] = *desc;
- if (desc->buf_type == TYPE_NETSEC_SKB)
- dring->desc[idx].skb = buf;
- else if (desc->buf_type == TYPE_NETSEC_XDP_TX ||
- desc->buf_type == TYPE_NETSEC_XDP_NDO)
- dring->desc[idx].xdpf = buf;
-
- /* move head ahead */
- dring->head = (dring->head + 1) % DESC_NUM;
-}
static int netsec_desc_used(struct netsec_desc_ring *dring)
{
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] net: netsec: remove superfluous if statement
2019-07-09 21:14 [PATCH 1/2] net: netsec: remove superfluous if statement Ilias Apalodimas
2019-07-09 21:14 ` [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de() Ilias Apalodimas
@ 2019-07-09 21:46 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-09 21:46 UTC (permalink / raw)
To: ilias.apalodimas; +Cc: netdev, jaswinder.singh
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Wed, 10 Jul 2019 00:14:48 +0300
> While freeing tx buffers the memory has to be unmapped if the packet was
> an skb or was used for .ndo_xdp_xmit using the same arguments. Get rid
> of the unneeded extra 'else if' statement
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de()
2019-07-09 21:14 ` [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de() Ilias Apalodimas
@ 2019-07-09 21:47 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-09 21:47 UTC (permalink / raw)
To: ilias.apalodimas; +Cc: netdev, jaswinder.singh
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Wed, 10 Jul 2019 00:14:49 +0300
> On commit ba2b232108d3 ("net: netsec: add XDP support") a static
> declaration for netsec_set_tx_de() was added to make the diff easier
> to read. Now that the patch is merged let's move the functions around
> and get rid of that
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-09 21:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-09 21:14 [PATCH 1/2] net: netsec: remove superfluous if statement Ilias Apalodimas
2019-07-09 21:14 ` [PATCH 2/2] net: netsec: remove static declaration for netsec_set_tx_de() Ilias Apalodimas
2019-07-09 21:47 ` David Miller
2019-07-09 21:46 ` [PATCH 1/2] net: netsec: remove superfluous if statement David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.