Skip to content

Commit 8a8982d

Browse files
committed
Merge branch 'netsec-driver-improvements'
Ilias Apalodimas says: ==================== netsec driver improvements This patchset introduces some improvements on socionext netsec driver. - patch 1/2, avoids unneeded MMIO reads on the Rx path - patch 2/2, is adjusting the numbers of descriptors used Changes since v1: - Move dma_rmb() to protect descriptor accesses until the device has updated the NETSEC_RX_PKT_OWN_FIELD bit ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 78aca3b + b6311b7 commit 8a8982d

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/net/ethernet/socionext/netsec.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@
232232
#define NETSEC_EEPROM_PKT_ME_ADDRESS 0x20
233233
#define NETSEC_EEPROM_PKT_ME_SIZE 0x24
234234

235-
#define DESC_NUM 128
236-
#define NAPI_BUDGET (DESC_NUM / 2)
235+
#define DESC_NUM 256
237236

238237
#define DESC_SZ sizeof(struct netsec_de)
239238

@@ -642,8 +641,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,
642641

643642
tmp_skb = netsec_alloc_skb(priv, &td);
644643

645-
dma_rmb();
646-
647644
tail = dring->tail;
648645

649646
if (!tmp_skb) {
@@ -657,8 +654,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,
657654
/* move tail ahead */
658655
dring->tail = (dring->tail + 1) % DESC_NUM;
659656

660-
dring->pkt_cnt--;
661-
662657
return skb;
663658
}
664659

@@ -731,25 +726,24 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
731726
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
732727
struct net_device *ndev = priv->ndev;
733728
struct netsec_rx_pkt_info rx_info;
734-
int done = 0, rx_num = 0;
729+
int done = 0;
735730
struct netsec_desc desc;
736731
struct sk_buff *skb;
737732
u16 len;
738733

739734
while (done < budget) {
740-
if (!rx_num) {
741-
rx_num = netsec_read(priv, NETSEC_REG_NRM_RX_PKTCNT);
742-
dring->pkt_cnt += rx_num;
735+
u16 idx = dring->tail;
736+
struct netsec_de *de = dring->vaddr + (DESC_SZ * idx);
743737

744-
/* move head 'rx_num' */
745-
dring->head = (dring->head + rx_num) % DESC_NUM;
738+
if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
739+
break;
746740

747-
rx_num = dring->pkt_cnt;
748-
if (!rx_num)
749-
break;
750-
}
741+
/* This barrier is needed to keep us from reading
742+
* any other fields out of the netsec_de until we have
743+
* verified the descriptor has been written back
744+
*/
745+
dma_rmb();
751746
done++;
752-
rx_num--;
753747
skb = netsec_get_rx_pkt_data(priv, &rx_info, &desc, &len);
754748
if (unlikely(!skb) || rx_info.err_flag) {
755749
netif_err(priv, drv, priv->ndev,
@@ -1664,7 +1658,7 @@ static int netsec_probe(struct platform_device *pdev)
16641658
dev_info(&pdev->dev, "hardware revision %d.%d\n",
16651659
hw_ver >> 16, hw_ver & 0xffff);
16661660

1667-
netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_BUDGET);
1661+
netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_POLL_WEIGHT);
16681662

16691663
ndev->netdev_ops = &netsec_netdev_ops;
16701664
ndev->ethtool_ops = &netsec_ethtool_ops;

0 commit comments

Comments
 (0)