Skip to content

Commit e43d15c

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 40GbE Intel Wired LAN Driver Updates 2016-04-05 This series contains updates to i40e and i40evf only. Stefan converts dev_close() to ndo_stop() for ethtool offline self test, since dev_close() causes IFF_UP to be cleared which will remove the interface routes and addresses. Alex bumps up the size of the transmit data buffer to 12K rather than 8K, which provides a gain in throughput and a reduction in overhead for putting together the frame. Fixed an issue in the polling routines where we were using bitwise operators to avoid the side effects of the logical operators. Then added support for bulk transmit clean for skbs. Jesse fixed a sparse issue in the type casting in the transmit code and fixed i40e_aq_set_phy_debug() to use i40e_status as a return code. Catherine cleans up duplicated code. Shannon fixed the cleaning up of the interrupt handling to clean up the IRQs only if we actually got them set up. Also fixed up the error scenarios where we were trying to remove a non-existent timer or worktask, which causes the kernel heartburn. Mitch changes the notification of resets to the reset interrupt handler, instead of the actual reset initiation code. This allows the VFs to get properly notified for all resets, including resets initiated by different PFs on the same physical device. Also moved the clearing of VFLR bit after reset processing, instead of before which could lead to double resets on VF init. Fixed code comment to match the actual function name. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f1cc809 + 50f26a5 commit e43d15c

File tree

11 files changed

+166
-88
lines changed

11 files changed

+166
-88
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ struct i40e_fdir_filter {
244244
#define I40E_DCB_PRIO_TYPE_STRICT 0
245245
#define I40E_DCB_PRIO_TYPE_ETS 1
246246
#define I40E_DCB_STRICT_PRIO_CREDITS 127
247-
#define I40E_MAX_USER_PRIORITY 8
248247
/* DCB per TC information data structure */
249248
struct i40e_tc_info {
250249
u16 qoffset; /* Queue offset from base queue */
@@ -811,6 +810,7 @@ int i40e_vlan_rx_kill_vid(struct net_device *netdev,
811810
__always_unused __be16 proto, u16 vid);
812811
#endif
813812
int i40e_open(struct net_device *netdev);
813+
int i40e_close(struct net_device *netdev);
814814
int i40e_vsi_open(struct i40e_vsi *vsi);
815815
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
816816
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
@@ -823,7 +823,6 @@ bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
823823
struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, u8 *macaddr,
824824
bool is_vf, bool is_netdev);
825825
#ifdef I40E_FCOE
826-
int i40e_close(struct net_device *netdev);
827826
int __i40e_setup_tc(struct net_device *netdev, u32 handle, __be16 proto,
828827
struct tc_to_netdev *tc);
829828
void i40e_netpoll(struct net_device *netdev);

drivers/net/ethernet/intel/i40e/i40e_common.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,13 +1901,13 @@ i40e_status i40e_aq_set_phy_int_mask(struct i40e_hw *hw,
19011901
*
19021902
* Reset the external PHY.
19031903
**/
1904-
enum i40e_status_code i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
1905-
struct i40e_asq_cmd_details *cmd_details)
1904+
i40e_status i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
1905+
struct i40e_asq_cmd_details *cmd_details)
19061906
{
19071907
struct i40e_aq_desc desc;
19081908
struct i40e_aqc_set_phy_debug *cmd =
19091909
(struct i40e_aqc_set_phy_debug *)&desc.params.raw;
1910-
enum i40e_status_code status;
1910+
i40e_status status;
19111911

19121912
i40e_fill_default_direct_cmd_desc(&desc,
19131913
i40e_aqc_opc_set_phy_debug);
@@ -2157,6 +2157,9 @@ i40e_status i40e_aq_update_vsi_params(struct i40e_hw *hw,
21572157
struct i40e_aq_desc desc;
21582158
struct i40e_aqc_add_get_update_vsi *cmd =
21592159
(struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
2160+
struct i40e_aqc_add_get_update_vsi_completion *resp =
2161+
(struct i40e_aqc_add_get_update_vsi_completion *)
2162+
&desc.params.raw;
21602163
i40e_status status;
21612164

21622165
i40e_fill_default_direct_cmd_desc(&desc,
@@ -2168,6 +2171,9 @@ i40e_status i40e_aq_update_vsi_params(struct i40e_hw *hw,
21682171
status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
21692172
sizeof(vsi_ctx->info), cmd_details);
21702173

2174+
vsi_ctx->vsis_allocated = le16_to_cpu(resp->vsi_used);
2175+
vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
2176+
21712177
return status;
21722178
}
21732179

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ static void i40e_diag_test(struct net_device *netdev,
17141714
/* If the device is online then take it offline */
17151715
if (if_running)
17161716
/* indicate we're in test mode */
1717-
dev_close(netdev);
1717+
i40e_close(netdev);
17181718
else
17191719
/* This reset does not affect link - if it is
17201720
* changed to a type of reset that does affect
@@ -1743,7 +1743,7 @@ static void i40e_diag_test(struct net_device *netdev,
17431743
i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
17441744

17451745
if (if_running)
1746-
dev_open(netdev);
1746+
i40e_open(netdev);
17471747
} else {
17481748
/* Online tests */
17491749
netif_info(pf, drv, netdev, "online testing starting\n");

drivers/net/ethernet/intel/i40e/i40e_fcoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static netdev_tx_t i40e_fcoe_xmit_frame(struct sk_buff *skb,
13711371
if (i40e_chk_linearize(skb, count)) {
13721372
if (__skb_linearize(skb))
13731373
goto out_drop;
1374-
count = TXD_USE_COUNT(skb->len);
1374+
count = i40e_txd_use_count(skb->len);
13751375
tx_ring->tx_stats.tx_linearize++;
13761376
}
13771377

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ static const char i40e_driver_string[] =
4545
#define DRV_KERN "-k"
4646

4747
#define DRV_VERSION_MAJOR 1
48-
#define DRV_VERSION_MINOR 4
49-
#define DRV_VERSION_BUILD 25
48+
#define DRV_VERSION_MINOR 5
49+
#define DRV_VERSION_BUILD 1
5050
#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
5151
__stringify(DRV_VERSION_MINOR) "." \
5252
__stringify(DRV_VERSION_BUILD) DRV_KERN
@@ -4164,7 +4164,7 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf)
41644164
int i;
41654165

41664166
i40e_stop_misc_vector(pf);
4167-
if (pf->flags & I40E_FLAG_MSIX_ENABLED) {
4167+
if (pf->flags & I40E_FLAG_MSIX_ENABLED && pf->msix_entries) {
41684168
synchronize_irq(pf->msix_entries[0].vector);
41694169
free_irq(pf->msix_entries[0].vector, pf);
41704170
}
@@ -5509,11 +5509,7 @@ static void i40e_fdir_filter_exit(struct i40e_pf *pf)
55095509
*
55105510
* Returns 0, this is not allowed to fail
55115511
**/
5512-
#ifdef I40E_FCOE
55135512
int i40e_close(struct net_device *netdev)
5514-
#else
5515-
static int i40e_close(struct net_device *netdev)
5516-
#endif
55175513
{
55185514
struct i40e_netdev_priv *np = netdev_priv(netdev);
55195515
struct i40e_vsi *vsi = np->vsi;
@@ -5538,8 +5534,6 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
55385534

55395535
WARN_ON(in_interrupt());
55405536

5541-
if (i40e_check_asq_alive(&pf->hw))
5542-
i40e_vc_notify_reset(pf);
55435537

55445538
/* do the biggest reset indicated */
55455539
if (reset_flags & BIT_ULL(__I40E_GLOBAL_RESET_REQUESTED)) {
@@ -6377,7 +6371,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
63776371
break;
63786372
default:
63796373
dev_info(&pf->pdev->dev,
6380-
"ARQ Error: Unknown event 0x%04x received\n",
6374+
"ARQ: Unknown event 0x%04x ignored\n",
63816375
opcode);
63826376
break;
63836377
}
@@ -6742,6 +6736,8 @@ static void i40e_prep_for_reset(struct i40e_pf *pf)
67426736
clear_bit(__I40E_RESET_INTR_RECEIVED, &pf->state);
67436737
if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state))
67446738
return;
6739+
if (i40e_check_asq_alive(&pf->hw))
6740+
i40e_vc_notify_reset(pf);
67456741

67466742
dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n");
67476743

@@ -10826,6 +10822,12 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1082610822
hw->bus.func = PCI_FUNC(pdev->devfn);
1082710823
pf->instance = pfs_found;
1082810824

10825+
/* set up the locks for the AQ, do this only once in probe
10826+
* and destroy them only once in remove
10827+
*/
10828+
mutex_init(&hw->aq.asq_mutex);
10829+
mutex_init(&hw->aq.arq_mutex);
10830+
1082910831
if (debug != -1) {
1083010832
pf->msg_enable = pf->hw.debug_mask;
1083110833
pf->msg_enable = debug;
@@ -10871,12 +10873,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1087110873
/* set up a default setting for link flow control */
1087210874
pf->hw.fc.requested_mode = I40E_FC_NONE;
1087310875

10874-
/* set up the locks for the AQ, do this only once in probe
10875-
* and destroy them only once in remove
10876-
*/
10877-
mutex_init(&hw->aq.asq_mutex);
10878-
mutex_init(&hw->aq.arq_mutex);
10879-
1088010876
err = i40e_init_adminq(hw);
1088110877
if (err) {
1088210878
if (err == I40E_ERR_FIRMWARE_API_VERSION)
@@ -11269,7 +11265,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1126911265
kfree(pf->qp_pile);
1127011266
err_sw_init:
1127111267
err_adminq_setup:
11272-
(void)i40e_shutdown_adminq(hw);
1127311268
err_pf_reset:
1127411269
iounmap(hw->hw_addr);
1127511270
err_ioremap:
@@ -11311,8 +11306,10 @@ static void i40e_remove(struct pci_dev *pdev)
1131111306
/* no more scheduling of any task */
1131211307
set_bit(__I40E_SUSPENDED, &pf->state);
1131311308
set_bit(__I40E_DOWN, &pf->state);
11314-
del_timer_sync(&pf->service_timer);
11315-
cancel_work_sync(&pf->service_task);
11309+
if (pf->service_timer.data)
11310+
del_timer_sync(&pf->service_timer);
11311+
if (pf->service_task.func)
11312+
cancel_work_sync(&pf->service_task);
1131611313

1131711314
if (pf->flags & I40E_FLAG_SRIOV_ENABLED) {
1131811315
i40e_free_vfs(pf);

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -636,19 +636,21 @@ u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw)
636636

637637
/**
638638
* i40e_clean_tx_irq - Reclaim resources after transmit completes
639-
* @tx_ring: tx ring to clean
640-
* @budget: how many cleans we're allowed
639+
* @vsi: the VSI we care about
640+
* @tx_ring: Tx ring to clean
641+
* @napi_budget: Used to determine if we are in netpoll
641642
*
642643
* Returns true if there's any budget left (e.g. the clean is finished)
643644
**/
644-
static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
645+
static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
646+
struct i40e_ring *tx_ring, int napi_budget)
645647
{
646648
u16 i = tx_ring->next_to_clean;
647649
struct i40e_tx_buffer *tx_buf;
648650
struct i40e_tx_desc *tx_head;
649651
struct i40e_tx_desc *tx_desc;
650-
unsigned int total_packets = 0;
651-
unsigned int total_bytes = 0;
652+
unsigned int total_bytes = 0, total_packets = 0;
653+
unsigned int budget = vsi->work_limit;
652654

653655
tx_buf = &tx_ring->tx_bi[i];
654656
tx_desc = I40E_TX_DESC(tx_ring, i);
@@ -678,7 +680,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
678680
total_packets += tx_buf->gso_segs;
679681

680682
/* free the skb */
681-
dev_consume_skb_any(tx_buf->skb);
683+
napi_consume_skb(tx_buf->skb, napi_budget);
682684

683685
/* unmap skb header data */
684686
dma_unmap_single(tx_ring->dev,
@@ -749,7 +751,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
749751

750752
if (budget &&
751753
((j / (WB_STRIDE + 1)) == 0) && (j != 0) &&
752-
!test_bit(__I40E_DOWN, &tx_ring->vsi->state) &&
754+
!test_bit(__I40E_DOWN, &vsi->state) &&
753755
(I40E_DESC_UNUSED(tx_ring) != tx_ring->count))
754756
tx_ring->arm_wb = true;
755757
}
@@ -767,7 +769,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
767769
smp_mb();
768770
if (__netif_subqueue_stopped(tx_ring->netdev,
769771
tx_ring->queue_index) &&
770-
!test_bit(__I40E_DOWN, &tx_ring->vsi->state)) {
772+
!test_bit(__I40E_DOWN, &vsi->state)) {
771773
netif_wake_subqueue(tx_ring->netdev,
772774
tx_ring->queue_index);
773775
++tx_ring->tx_stats.restart_queue;
@@ -1975,9 +1977,11 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)
19751977
* budget and be more aggressive about cleaning up the Tx descriptors.
19761978
*/
19771979
i40e_for_each_ring(ring, q_vector->tx) {
1978-
clean_complete = clean_complete &&
1979-
i40e_clean_tx_irq(ring, vsi->work_limit);
1980-
arm_wb = arm_wb || ring->arm_wb;
1980+
if (!i40e_clean_tx_irq(vsi, ring, budget)) {
1981+
clean_complete = false;
1982+
continue;
1983+
}
1984+
arm_wb |= ring->arm_wb;
19811985
ring->arm_wb = false;
19821986
}
19831987

@@ -1999,8 +2003,9 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)
19992003
cleaned = i40e_clean_rx_irq_1buf(ring, budget_per_ring);
20002004

20012005
work_done += cleaned;
2002-
/* if we didn't clean as many as budgeted, we must be done */
2003-
clean_complete = clean_complete && (budget_per_ring > cleaned);
2006+
/* if we clean as many as budgeted, we must not be done */
2007+
if (cleaned >= budget_per_ring)
2008+
clean_complete = false;
20042009
}
20052010

20062011
/* If work not completed, return budget and polling will return */
@@ -2300,7 +2305,8 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
23002305

23012306
/* remove payload length from outer checksum */
23022307
paylen = (__force u16)l4.udp->check;
2303-
paylen += ntohs(1) * (u16)~(skb->len - l4_offset);
2308+
paylen += ntohs((__force __be16)1) *
2309+
(u16)~(skb->len - l4_offset);
23042310
l4.udp->check = ~csum_fold((__force __wsum)paylen);
23052311
}
23062312

@@ -2322,7 +2328,7 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
23222328

23232329
/* remove payload length from inner checksum */
23242330
paylen = (__force u16)l4.tcp->check;
2325-
paylen += ntohs(1) * (u16)~(skb->len - l4_offset);
2331+
paylen += ntohs((__force __be16)1) * (u16)~(skb->len - l4_offset);
23262332
l4.tcp->check = ~csum_fold((__force __wsum)paylen);
23272333

23282334
/* compute length of segmentation header */
@@ -2717,19 +2723,23 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
27172723
tx_bi = first;
27182724

27192725
for (frag = &skb_shinfo(skb)->frags[0];; frag++) {
2726+
unsigned int max_data = I40E_MAX_DATA_PER_TXD_ALIGNED;
2727+
27202728
if (dma_mapping_error(tx_ring->dev, dma))
27212729
goto dma_error;
27222730

27232731
/* record length, and DMA address */
27242732
dma_unmap_len_set(tx_bi, len, size);
27252733
dma_unmap_addr_set(tx_bi, dma, dma);
27262734

2735+
/* align size to end of page */
2736+
max_data += -dma & (I40E_MAX_READ_REQ_SIZE - 1);
27272737
tx_desc->buffer_addr = cpu_to_le64(dma);
27282738

27292739
while (unlikely(size > I40E_MAX_DATA_PER_TXD)) {
27302740
tx_desc->cmd_type_offset_bsz =
27312741
build_ctob(td_cmd, td_offset,
2732-
I40E_MAX_DATA_PER_TXD, td_tag);
2742+
max_data, td_tag);
27332743

27342744
tx_desc++;
27352745
i++;
@@ -2740,9 +2750,10 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
27402750
i = 0;
27412751
}
27422752

2743-
dma += I40E_MAX_DATA_PER_TXD;
2744-
size -= I40E_MAX_DATA_PER_TXD;
2753+
dma += max_data;
2754+
size -= max_data;
27452755

2756+
max_data = I40E_MAX_DATA_PER_TXD_ALIGNED;
27462757
tx_desc->buffer_addr = cpu_to_le64(dma);
27472758
}
27482759

@@ -2892,7 +2903,7 @@ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb,
28922903
if (i40e_chk_linearize(skb, count)) {
28932904
if (__skb_linearize(skb))
28942905
goto out_drop;
2895-
count = TXD_USE_COUNT(skb->len);
2906+
count = i40e_txd_use_count(skb->len);
28962907
tx_ring->tx_stats.tx_linearize++;
28972908
}
28982909

drivers/net/ethernet/intel/i40e/i40e_txrx.h

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,39 @@ enum i40e_dyn_idx_t {
146146

147147
#define I40E_MAX_BUFFER_TXD 8
148148
#define I40E_MIN_TX_LEN 17
149-
#define I40E_MAX_DATA_PER_TXD 8192
149+
150+
/* The size limit for a transmit buffer in a descriptor is (16K - 1).
151+
* In order to align with the read requests we will align the value to
152+
* the nearest 4K which represents our maximum read request size.
153+
*/
154+
#define I40E_MAX_READ_REQ_SIZE 4096
155+
#define I40E_MAX_DATA_PER_TXD (16 * 1024 - 1)
156+
#define I40E_MAX_DATA_PER_TXD_ALIGNED \
157+
(I40E_MAX_DATA_PER_TXD & ~(I40E_MAX_READ_REQ_SIZE - 1))
158+
159+
/* This ugly bit of math is equivalent to DIV_ROUNDUP(size, X) where X is
160+
* the value I40E_MAX_DATA_PER_TXD_ALIGNED. It is needed due to the fact
161+
* that 12K is not a power of 2 and division is expensive. It is used to
162+
* approximate the number of descriptors used per linear buffer. Note
163+
* that this will overestimate in some cases as it doesn't account for the
164+
* fact that we will add up to 4K - 1 in aligning the 12K buffer, however
165+
* the error should not impact things much as large buffers usually mean
166+
* we will use fewer descriptors then there are frags in an skb.
167+
*/
168+
static inline unsigned int i40e_txd_use_count(unsigned int size)
169+
{
170+
const unsigned int max = I40E_MAX_DATA_PER_TXD_ALIGNED;
171+
const unsigned int reciprocal = ((1ull << 32) - 1 + (max / 2)) / max;
172+
unsigned int adjust = ~(u32)0;
173+
174+
/* if we rounded up on the reciprocal pull down the adjustment */
175+
if ((max * reciprocal) > adjust)
176+
adjust = ~(u32)(reciprocal - 1);
177+
178+
return (u32)((((u64)size * reciprocal) + adjust) >> 32);
179+
}
150180

151181
/* Tx Descriptors needed, worst case */
152-
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), I40E_MAX_DATA_PER_TXD)
153182
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
154183
#define I40E_MIN_DESC_PENDING 4
155184

@@ -377,7 +406,7 @@ static inline int i40e_xmit_descriptor_count(struct sk_buff *skb)
377406
int count = 0, size = skb_headlen(skb);
378407

379408
for (;;) {
380-
count += TXD_USE_COUNT(size);
409+
count += i40e_txd_use_count(size);
381410

382411
if (!nr_frags--)
383412
break;

0 commit comments

Comments
 (0)