Message ID | 1572928001-6915-1-git-send-email-yanjun.zhu@oracle.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | [PATCHv4,1/1] net: forcedeth: add xmit_more support | expand |
On Mon, 4 Nov 2019 23:26:41 -0500, Zhu Yanjun wrote: > diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c > index 05d2b47..0d21ddd 100644 > --- a/drivers/net/ethernet/nvidia/forcedeth.c > +++ b/drivers/net/ethernet/nvidia/forcedeth.c > @@ -2259,7 +2265,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) > u64_stats_update_begin(&np->swstats_tx_syncp); > nv_txrx_stats_inc(stat_tx_dropped); > u64_stats_update_end(&np->swstats_tx_syncp); > - return NETDEV_TX_OK; > + > + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, > + get_hwbase(dev) + NvRegTxRxControl); > + ret = NETDEV_TX_OK; > + > + goto dma_error; You could goto the middle of the txkick if statement here, instead of duplicating the writel()? Actually the txkick label could be in the middle of the if statement to begin with, TXBUSY case above stops the queue so it will always go into the if. > } > np->put_tx_ctx->dma_len = bcnt; > np->put_tx_ctx->dma_single = 1; > @@ -2305,7 +2316,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) > u64_stats_update_begin(&np->swstats_tx_syncp); > nv_txrx_stats_inc(stat_tx_dropped); > u64_stats_update_end(&np->swstats_tx_syncp); > - return NETDEV_TX_OK; > + > + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, > + get_hwbase(dev) + NvRegTxRxControl); > + ret = NETDEV_TX_OK; > + > + goto dma_error; And here. > } > > np->put_tx_ctx->dma_len = bcnt; > @@ -2357,8 +2373,15 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) > > spin_unlock_irqrestore(&np->lock, flags); > > - writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); > - return NETDEV_TX_OK; > +txkick: > + if (netif_queue_stopped(dev) || !netdev_xmit_more()) { > + u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; > + > + writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); > + } > + > +dma_error: > + return ret; > } But otherwise looks correct to me now, thanks!
On 2019/11/6 1:48, Jakub Kicinski wrote: > On Mon, 4 Nov 2019 23:26:41 -0500, Zhu Yanjun wrote: >> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c >> index 05d2b47..0d21ddd 100644 >> --- a/drivers/net/ethernet/nvidia/forcedeth.c >> +++ b/drivers/net/ethernet/nvidia/forcedeth.c >> @@ -2259,7 +2265,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) >> u64_stats_update_begin(&np->swstats_tx_syncp); >> nv_txrx_stats_inc(stat_tx_dropped); >> u64_stats_update_end(&np->swstats_tx_syncp); >> - return NETDEV_TX_OK; >> + >> + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, >> + get_hwbase(dev) + NvRegTxRxControl); >> + ret = NETDEV_TX_OK; >> + >> + goto dma_error; > You could goto the middle of the txkick if statement here, instead of > duplicating the writel()? As your suggestion, the change is like this: @@ -2374,7 +2374,9 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&np->lock, flags); txkick: - if (netif_queue_stopped(dev) || !netdev_xmit_more()) { + if (netif_queue_stopped(dev) || !netdev_xmit_more()) +dma_error: + { u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); The opening brace on the first of the line. It conflicts with the following: Documentation/process/coding-style.rst: " 98 3) Placing Braces and Spaces 99 ---------------------------- 100 101 The other issue that always comes up in C styling is the placement of 102 braces. Unlike the indent size, there are few technical reasons to 103 choose one placement strategy over the other, but the preferred way, as 104 shown to us by the prophets Kernighan and Ritchie, is to put the opening 105 brace last on the line, and put the closing brace first, thusly: " So I prefer to the current code style. Thanks for your suggestions. Any way, it is a code style problem. It is trivial. > Actually the txkick label could be in the > middle of the if statement to begin with, TXBUSY case above stops the > queue so it will always go into the if. > >> } >> np->put_tx_ctx->dma_len = bcnt; >> np->put_tx_ctx->dma_single = 1; >> @@ -2305,7 +2316,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) >> u64_stats_update_begin(&np->swstats_tx_syncp); >> nv_txrx_stats_inc(stat_tx_dropped); >> u64_stats_update_end(&np->swstats_tx_syncp); >> - return NETDEV_TX_OK; >> + >> + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, >> + get_hwbase(dev) + NvRegTxRxControl); >> + ret = NETDEV_TX_OK; >> + >> + goto dma_error; > And here. > >> } >> >> np->put_tx_ctx->dma_len = bcnt; >> @@ -2357,8 +2373,15 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) >> >> spin_unlock_irqrestore(&np->lock, flags); >> >> - writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); >> - return NETDEV_TX_OK; >> +txkick: >> + if (netif_queue_stopped(dev) || !netdev_xmit_more()) { >> + u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; >> + >> + writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); >> + } >> + >> +dma_error: >> + return ret; >> } > But otherwise looks correct to me now, thanks! Thanks a lot for code review. Zhu Yanjun >
On Wed, 6 Nov 2019 12:47:29 +0800, Zhu Yanjun wrote: > On 2019/11/6 1:48, Jakub Kicinski wrote: > > On Mon, 4 Nov 2019 23:26:41 -0500, Zhu Yanjun wrote: > >> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c > >> index 05d2b47..0d21ddd 100644 > >> --- a/drivers/net/ethernet/nvidia/forcedeth.c > >> +++ b/drivers/net/ethernet/nvidia/forcedeth.c > >> @@ -2259,7 +2265,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) > >> u64_stats_update_begin(&np->swstats_tx_syncp); > >> nv_txrx_stats_inc(stat_tx_dropped); > >> u64_stats_update_end(&np->swstats_tx_syncp); > >> - return NETDEV_TX_OK; > >> + > >> + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, > >> + get_hwbase(dev) + NvRegTxRxControl); > >> + ret = NETDEV_TX_OK; > >> + > >> + goto dma_error; > > You could goto the middle of the txkick if statement here, instead of > > duplicating the writel()? > As your suggestion, the change is like this: > > @@ -2374,7 +2374,9 @@ static netdev_tx_t nv_start_xmit(struct sk_buff > *skb, struct net_device *dev) > spin_unlock_irqrestore(&np->lock, flags); > > txkick: > - if (netif_queue_stopped(dev) || !netdev_xmit_more()) { > + if (netif_queue_stopped(dev) || !netdev_xmit_more()) > +dma_error: > + { > u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; > > writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); > > The opening brace on the first of the line. It conflicts with the following: > > Documentation/process/coding-style.rst: > " > 98 3) Placing Braces and Spaces > 99 ---------------------------- > 100 > 101 The other issue that always comes up in C styling is the placement of > 102 braces. Unlike the indent size, there are few technical reasons to > 103 choose one placement strategy over the other, but the preferred > way, as > 104 shown to us by the prophets Kernighan and Ritchie, is to put the > opening > 105 brace last on the line, and put the closing brace first, thusly: > " > So I prefer to the current code style. > > Thanks for your suggestions. if (netif_queue_stopped(dev) || !netdev_xmit_more()) { u32 txrxctl_kick; txkick: txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); }
On 2019/11/6 12:48, Jakub Kicinski wrote: > On Wed, 6 Nov 2019 12:47:29 +0800, Zhu Yanjun wrote: >> On 2019/11/6 1:48, Jakub Kicinski wrote: >>> On Mon, 4 Nov 2019 23:26:41 -0500, Zhu Yanjun wrote: >>>> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c >>>> index 05d2b47..0d21ddd 100644 >>>> --- a/drivers/net/ethernet/nvidia/forcedeth.c >>>> +++ b/drivers/net/ethernet/nvidia/forcedeth.c >>>> @@ -2259,7 +2265,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) >>>> u64_stats_update_begin(&np->swstats_tx_syncp); >>>> nv_txrx_stats_inc(stat_tx_dropped); >>>> u64_stats_update_end(&np->swstats_tx_syncp); >>>> - return NETDEV_TX_OK; >>>> + >>>> + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, >>>> + get_hwbase(dev) + NvRegTxRxControl); >>>> + ret = NETDEV_TX_OK; >>>> + >>>> + goto dma_error; >>> You could goto the middle of the txkick if statement here, instead of >>> duplicating the writel()? >> As your suggestion, the change is like this: >> >> @@ -2374,7 +2374,9 @@ static netdev_tx_t nv_start_xmit(struct sk_buff >> *skb, struct net_device *dev) >> spin_unlock_irqrestore(&np->lock, flags); >> >> txkick: >> - if (netif_queue_stopped(dev) || !netdev_xmit_more()) { >> + if (netif_queue_stopped(dev) || !netdev_xmit_more()) >> +dma_error: >> + { >> u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; >> >> writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); >> >> The opening brace on the first of the line. It conflicts with the following: >> >> Documentation/process/coding-style.rst: >> " >> 98 3) Placing Braces and Spaces >> 99 ---------------------------- >> 100 >> 101 The other issue that always comes up in C styling is the placement of >> 102 braces. Unlike the indent size, there are few technical reasons to >> 103 choose one placement strategy over the other, but the preferred >> way, as >> 104 shown to us by the prophets Kernighan and Ritchie, is to put the >> opening >> 105 brace last on the line, and put the closing brace first, thusly: >> " >> So I prefer to the current code style. >> >> Thanks for your suggestions. > if (netif_queue_stopped(dev) || !netdev_xmit_more()) { > u32 txrxctl_kick; > > txkick: > txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; > writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); > } Thanks a lot. Will send a new patch with the above changes. Zhu Yanjun >
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 05d2b47..0d21ddd 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -2225,6 +2225,7 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) struct nv_skb_map *prev_tx_ctx; struct nv_skb_map *tmp_tx_ctx = NULL, *start_tx_ctx = NULL; unsigned long flags; + netdev_tx_t ret = NETDEV_TX_OK; /* add fragments to entries count */ for (i = 0; i < fragments; i++) { @@ -2240,7 +2241,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); np->tx_stop = 1; spin_unlock_irqrestore(&np->lock, flags); - return NETDEV_TX_BUSY; + + /* When normal packets and/or xmit_more packets fill up + * tx_desc, it is necessary to trigger NIC tx reg. + */ + ret = NETDEV_TX_BUSY; + goto txkick; } spin_unlock_irqrestore(&np->lock, flags); @@ -2259,7 +2265,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) u64_stats_update_begin(&np->swstats_tx_syncp); nv_txrx_stats_inc(stat_tx_dropped); u64_stats_update_end(&np->swstats_tx_syncp); - return NETDEV_TX_OK; + + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, + get_hwbase(dev) + NvRegTxRxControl); + ret = NETDEV_TX_OK; + + goto dma_error; } np->put_tx_ctx->dma_len = bcnt; np->put_tx_ctx->dma_single = 1; @@ -2305,7 +2316,12 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) u64_stats_update_begin(&np->swstats_tx_syncp); nv_txrx_stats_inc(stat_tx_dropped); u64_stats_update_end(&np->swstats_tx_syncp); - return NETDEV_TX_OK; + + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, + get_hwbase(dev) + NvRegTxRxControl); + ret = NETDEV_TX_OK; + + goto dma_error; } np->put_tx_ctx->dma_len = bcnt; @@ -2357,8 +2373,15 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&np->lock, flags); - writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); - return NETDEV_TX_OK; +txkick: + if (netif_queue_stopped(dev) || !netdev_xmit_more()) { + u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; + + writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); + } + +dma_error: + return ret; } static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, @@ -2381,6 +2404,7 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, struct nv_skb_map *start_tx_ctx = NULL; struct nv_skb_map *tmp_tx_ctx = NULL; unsigned long flags; + netdev_tx_t ret = NETDEV_TX_OK; /* add fragments to entries count */ for (i = 0; i < fragments; i++) { @@ -2396,7 +2420,13 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, netif_stop_queue(dev); np->tx_stop = 1; spin_unlock_irqrestore(&np->lock, flags); - return NETDEV_TX_BUSY; + + /* When normal packets and/or xmit_more packets fill up + * tx_desc, it is necessary to trigger NIC tx reg. + */ + ret = NETDEV_TX_BUSY; + + goto txkick; } spin_unlock_irqrestore(&np->lock, flags); @@ -2416,7 +2446,12 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, u64_stats_update_begin(&np->swstats_tx_syncp); nv_txrx_stats_inc(stat_tx_dropped); u64_stats_update_end(&np->swstats_tx_syncp); - return NETDEV_TX_OK; + + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, + get_hwbase(dev) + NvRegTxRxControl); + ret = NETDEV_TX_OK; + + goto dma_error; } np->put_tx_ctx->dma_len = bcnt; np->put_tx_ctx->dma_single = 1; @@ -2463,7 +2498,12 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, u64_stats_update_begin(&np->swstats_tx_syncp); nv_txrx_stats_inc(stat_tx_dropped); u64_stats_update_end(&np->swstats_tx_syncp); - return NETDEV_TX_OK; + + writel(NVREG_TXRXCTL_KICK | np->txrxctl_bits, + get_hwbase(dev) + NvRegTxRxControl); + ret = NETDEV_TX_OK; + + goto dma_error; } np->put_tx_ctx->dma_len = bcnt; np->put_tx_ctx->dma_single = 0; @@ -2542,8 +2582,15 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb, spin_unlock_irqrestore(&np->lock, flags); - writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); - return NETDEV_TX_OK; +txkick: + if (netif_queue_stopped(dev) || !netdev_xmit_more()) { + u32 txrxctl_kick = NVREG_TXRXCTL_KICK | np->txrxctl_bits; + + writel(txrxctl_kick, get_hwbase(dev) + NvRegTxRxControl); + } + +dma_error: + return ret; } static inline void nv_tx_flip_ownership(struct net_device *dev)
This change adds support for xmit_more based on the igb commit 6f19e12f6230 ("igb: flush when in xmit_more mode and under descriptor pressure") and commit 6b16f9ee89b8 ("net: move skb->xmit_more hint to softnet data") that were made to igb to support this feature. The function netif_xmit_stopped is called to check whether transmit queue on device is currently unable to send to determine whether we must write the tail because we can add no further buffers. When normal packets and/or xmit_more packets fill up tx_desc, it is necessary to trigger NIC tx reg. Following the advice from David Miller and Jakub Kicinski, after the xmit_more feature is added, the following scenario will occur. | xmit_more packets | DMA_MAPPING | DMA_MAPPING error check | xmit_more packets already in HW xmit queue | In the above scenario, if DMA_MAPPING error occurrs, the xmit_more packets already in HW xmit queue will also be dropped. This is different from the behavior before xmit_more feature. So it is necessary to trigger NIC HW tx reg in the above scenario. To the non-xmit_more packets, the above scenario will not occur. Tested: - pktgen (xmit_more packets) SMP x86_64 -> Test command: ./pktgen_sample03_burst_single_flow.sh ... -b 8 -n 1000000 Test results: Params: ... burst: 8 ... Result: OK: 12194004(c12188996+d5007) usec, 1000001 (1500byte,0frags) 82007pps 984Mb/sec (984084000bps) errors: 0 - iperf (normal packets) SMP x86_64 -> Test command: Server: iperf -s Client: iperf -c serverip Result: TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 1.10 GBytes 942 Mbits/sec CC: Joe Jin <joe.jin@oracle.com> CC: JUNXIAO_BI <junxiao.bi@oracle.com> Reported-and-tested-by: Nan san <nan.1986san@gmail.com> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com> --- V3->V4: fix DMA mapping errors handler with xmit_more feature. V2->V3: fix typo errors. V1->V2: use the lower case label. --- drivers/net/ethernet/nvidia/forcedeth.c | 67 ++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 10 deletions(-)