Skip to content

Commit e27a879

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 2017-07-25 This series contains updates to i40e and i40evf only. Gustavo Silva fixes a variable assignment, where the incorrect variable was being used to store the error parameter. Carolyn provides a fix for a problem found in systems when entering S4 state, by ensuring that the misc vector's IRQ is disabled as well. Jake removes the single-threaded restriction on the module workqueue, which was causing issues with events such as CORER. Does some future proofing, by changing how the driver displays the UDP tunnel type. Paul adds a retry in releasing resources if the admin queue times out during the first attempt to release the resources. Jesse fixes up references to 32bit timspec, since there are a small set of errors on 32 bit, so we need to be using the right calls for dealing with timespec64 variables. Cleaned up code indentation and corrected an "if" conditional check, as well as making the code flow more clear. Cast or changed the types to remove warnings for comparing signed and unsigned types. Adds missing includes in i40evf, which were being used but were not being directly included. Daniel Borkmann fixes i40e to fill the XDP prog_id with the id just like other XDP enabled drivers, so that on dump we can retrieve the attached program based on the id and dump BPF insns, opcodes, etc back to user space. Tushar Dave adds le32_to_cpu while evaluating the hardware descriptor fields, since they are in little-endian format. Also removed unnecessary "__packed" to a couple of i40evf structures. Stefan Assmann fixes an issue when an administratively set MAC was set and should now be switched back to 00:00:00:00:00:00, the pf_set_mac flag is not being toggled back to false. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 143f0cf + 2f1d86e commit e27a879

File tree

11 files changed

+122
-56
lines changed

11 files changed

+122
-56
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
10911091
struct i40e_pf *pf = np->vsi->back;
10921092
struct i40e_hw *hw = &pf->hw;
10931093
u32 *reg_buf = p;
1094-
int i, j, ri;
1094+
unsigned int i, j, ri;
10951095
u32 reg;
10961096

10971097
/* Tell ethtool which driver-version-specific regs output we have.
@@ -1550,9 +1550,9 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
15501550
struct i40e_ring *tx_ring, *rx_ring;
15511551
struct i40e_vsi *vsi = np->vsi;
15521552
struct i40e_pf *pf = vsi->back;
1553+
unsigned int j;
15531554
int i = 0;
15541555
char *p;
1555-
int j;
15561556
struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
15571557
unsigned int start;
15581558

@@ -1637,7 +1637,7 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
16371637
struct i40e_vsi *vsi = np->vsi;
16381638
struct i40e_pf *pf = vsi->back;
16391639
char *p = (char *)data;
1640-
int i;
1640+
unsigned int i;
16411641

16421642
switch (stringset) {
16431643
case ETH_SS_TEST:

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

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4773,7 +4773,7 @@ static void i40e_detect_recover_hung(struct i40e_pf *pf)
47734773
{
47744774
struct net_device *netdev;
47754775
struct i40e_vsi *vsi;
4776-
int i;
4776+
unsigned int i;
47774777

47784778
/* Only for LAN VSI */
47794779
vsi = pf->vsi[pf->lan_vsi];
@@ -7520,6 +7520,18 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
75207520
i40e_flush(hw);
75217521
}
75227522

7523+
static const char *i40e_tunnel_name(struct i40e_udp_port_config *port)
7524+
{
7525+
switch (port->type) {
7526+
case UDP_TUNNEL_TYPE_VXLAN:
7527+
return "vxlan";
7528+
case UDP_TUNNEL_TYPE_GENEVE:
7529+
return "geneve";
7530+
default:
7531+
return "unknown";
7532+
}
7533+
}
7534+
75237535
/**
75247536
* i40e_sync_udp_filters - Trigger a sync event for existing UDP filters
75257537
* @pf: board private structure
@@ -7565,14 +7577,14 @@ static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)
75657577
ret = i40e_aq_del_udp_tunnel(hw, i, NULL);
75667578

75677579
if (ret) {
7568-
dev_dbg(&pf->pdev->dev,
7569-
"%s %s port %d, index %d failed, err %s aq_err %s\n",
7570-
pf->udp_ports[i].type ? "vxlan" : "geneve",
7571-
port ? "add" : "delete",
7572-
port, i,
7573-
i40e_stat_str(&pf->hw, ret),
7574-
i40e_aq_str(&pf->hw,
7575-
pf->hw.aq.asq_last_status));
7580+
dev_info(&pf->pdev->dev,
7581+
"%s %s port %d, index %d failed, err %s aq_err %s\n",
7582+
i40e_tunnel_name(&pf->udp_ports[i]),
7583+
port ? "add" : "delete",
7584+
port, i,
7585+
i40e_stat_str(&pf->hw, ret),
7586+
i40e_aq_str(&pf->hw,
7587+
pf->hw.aq.asq_last_status));
75767588
pf->udp_ports[i].port = 0;
75777589
}
75787590
}
@@ -9589,6 +9601,7 @@ static int i40e_xdp(struct net_device *dev,
95899601
return i40e_xdp_setup(vsi, xdp->prog);
95909602
case XDP_QUERY_PROG:
95919603
xdp->prog_attached = i40e_enabled_xdp_vsi(vsi);
9604+
xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0;
95929605
return 0;
95939606
default:
95949607
return -EINVAL;
@@ -12089,7 +12102,10 @@ static int i40e_suspend(struct pci_dev *pdev, pm_message_t state)
1208912102
wr32(hw, I40E_PFPM_WUFC, (pf->wol_en ? I40E_PFPM_WUFC_MAG_MASK : 0));
1209012103

1209112104
i40e_stop_misc_vector(pf);
12092-
12105+
if (pf->msix_entries) {
12106+
synchronize_irq(pf->msix_entries[0].vector);
12107+
free_irq(pf->msix_entries[0].vector, pf);
12108+
}
1209312109
retval = pci_save_state(pdev);
1209412110
if (retval)
1209512111
return retval;
@@ -12129,6 +12145,15 @@ static int i40e_resume(struct pci_dev *pdev)
1212912145
/* handling the reset will rebuild the device state */
1213012146
if (test_and_clear_bit(__I40E_SUSPENDED, pf->state)) {
1213112147
clear_bit(__I40E_DOWN, pf->state);
12148+
if (pf->msix_entries) {
12149+
err = request_irq(pf->msix_entries[0].vector,
12150+
i40e_intr, 0, pf->int_name, pf);
12151+
if (err) {
12152+
dev_err(&pf->pdev->dev,
12153+
"request_irq for %s failed: %d\n",
12154+
pf->int_name, err);
12155+
}
12156+
}
1213212157
i40e_reset_and_rebuild(pf, false, false);
1213312158
}
1213412159

@@ -12168,12 +12193,14 @@ static int __init i40e_init_module(void)
1216812193
i40e_driver_string, i40e_driver_version_str);
1216912194
pr_info("%s: %s\n", i40e_driver_name, i40e_copyright);
1217012195

12171-
/* we will see if single thread per module is enough for now,
12172-
* it can't be any worse than using the system workqueue which
12173-
* was already single threaded
12196+
/* There is no need to throttle the number of active tasks because
12197+
* each device limits its own task using a state bit for scheduling
12198+
* the service task, and the device tasks do not interfere with each
12199+
* other, so we don't set a max task limit. We must set WQ_MEM_RECLAIM
12200+
* since we need to be able to guarantee forward progress even under
12201+
* memory pressure.
1217412202
*/
12175-
i40e_wq = alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1,
12176-
i40e_driver_name);
12203+
i40e_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0, i40e_driver_name);
1217712204
if (!i40e_wq) {
1217812205
pr_err("%s: Failed to create workqueue\n", i40e_driver_name);
1217912206
return -ENOMEM;

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,25 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
134134
**/
135135
void i40e_release_nvm(struct i40e_hw *hw)
136136
{
137-
if (!hw->nvm.blank_nvm_mode)
138-
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
137+
i40e_status ret_code = I40E_SUCCESS;
138+
u32 total_delay = 0;
139+
140+
if (hw->nvm.blank_nvm_mode)
141+
return;
142+
143+
ret_code = i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
144+
145+
/* there are some rare cases when trying to release the resource
146+
* results in an admin Q timeout, so handle them correctly
147+
*/
148+
while ((ret_code == I40E_ERR_ADMIN_QUEUE_TIMEOUT) &&
149+
(total_delay < hw->aq.asq_cmd_timeout)) {
150+
usleep_range(1000, 2000);
151+
ret_code = i40e_aq_release_resource(hw,
152+
I40E_NVM_RESOURCE_ID,
153+
0, NULL);
154+
total_delay++;
155+
}
139156
}
140157

141158
/**

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,12 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
158158
static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
159159
{
160160
struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
161-
struct timespec64 now, then;
161+
struct timespec64 now;
162162

163-
then = ns_to_timespec64(delta);
164163
mutex_lock(&pf->tmreg_lock);
165164

166165
i40e_ptp_read(pf, &now);
167-
now = timespec64_add(now, then);
166+
timespec64_add_ns(&now, delta);
168167
i40e_ptp_write(pf, (const struct timespec64 *)&now);
169168

170169
mutex_unlock(&pf->tmreg_lock);

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
860860
netdev_tx_completed_queue(txring_txq(tx_ring),
861861
total_packets, total_bytes);
862862

863-
#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)
863+
#define TX_WAKE_THRESHOLD ((s16)(DESC_NEEDED * 2))
864864
if (unlikely(total_packets && netif_carrier_ok(tx_ring->netdev) &&
865865
(I40E_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD))) {
866866
/* Make sure that anybody stopping the queue after this
@@ -2063,7 +2063,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
20632063
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
20642064
bool failure = false, xdp_xmit = false;
20652065

2066-
while (likely(total_rx_packets < budget)) {
2066+
while (likely(total_rx_packets < (unsigned int)budget)) {
20672067
struct i40e_rx_buffer *rx_buffer;
20682068
union i40e_rx_desc *rx_desc;
20692069
struct xdp_buff xdp;
@@ -2196,7 +2196,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
21962196
rx_ring->q_vector->rx.total_bytes += total_rx_bytes;
21972197

21982198
/* guarantee a trip back through this routine if there was a failure */
2199-
return failure ? budget : total_rx_packets;
2199+
return failure ? budget : (int)total_rx_packets;
22002200
}
22012201

22022202
static u32 i40e_buildreg_itr(const int type, const u16 itr)
@@ -2451,9 +2451,15 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
24512451
hlen = (hdr.network[0] & 0x0F) << 2;
24522452
l4_proto = hdr.ipv4->protocol;
24532453
} else {
2454-
hlen = hdr.network - skb->data;
2455-
l4_proto = ipv6_find_hdr(skb, &hlen, IPPROTO_TCP, NULL, NULL);
2456-
hlen -= hdr.network - skb->data;
2454+
/* find the start of the innermost ipv6 header */
2455+
unsigned int inner_hlen = hdr.network - skb->data;
2456+
unsigned int h_offset = inner_hlen;
2457+
2458+
/* this function updates h_offset to the end of the header */
2459+
l4_proto =
2460+
ipv6_find_hdr(skb, &h_offset, IPPROTO_TCP, NULL, NULL);
2461+
/* hlen will contain our best estimate of the tcp header */
2462+
hlen = h_offset - inner_hlen;
24572463
}
24582464

24592465
if (l4_proto != IPPROTO_TCP)

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
15671567
dev_err(&pf->pdev->dev,
15681568
"VF %d requested polling mode: this feature is supported only when the device is running in single function per port (SFP) mode\n",
15691569
vf->vf_id);
1570-
ret = I40E_ERR_PARAM;
1570+
aq_ret = I40E_ERR_PARAM;
15711571
goto err;
15721572
}
15731573
vfres->vf_offload_flags |= VIRTCHNL_VF_OFFLOAD_RX_POLLING;
@@ -1741,16 +1741,14 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
17411741
NULL);
17421742
} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
17431743
hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
1744-
aq_ret = 0;
1745-
if (f->vlan >= 0 && f->vlan <= I40E_MAX_VLANID) {
1746-
aq_ret =
1747-
i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
1748-
vsi->seid,
1749-
alluni,
1750-
f->vlan,
1751-
NULL);
1752-
aq_err = pf->hw.aq.asq_last_status;
1753-
}
1744+
if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
1745+
continue;
1746+
aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
1747+
vsi->seid,
1748+
alluni,
1749+
f->vlan,
1750+
NULL);
1751+
aq_err = pf->hw.aq.asq_last_status;
17541752
if (aq_ret)
17551753
dev_err(&pf->pdev->dev,
17561754
"Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n",
@@ -2764,15 +2762,23 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
27642762

27652763
spin_unlock_bh(&vsi->mac_filter_hash_lock);
27662764

2767-
dev_info(&pf->pdev->dev, "Setting MAC %pM on VF %d\n", mac, vf_id);
27682765
/* program mac filter */
27692766
if (i40e_sync_vsi_filters(vsi)) {
27702767
dev_err(&pf->pdev->dev, "Unable to program ucast filters\n");
27712768
ret = -EIO;
27722769
goto error_param;
27732770
}
27742771
ether_addr_copy(vf->default_lan_addr.addr, mac);
2775-
vf->pf_set_mac = true;
2772+
2773+
if (is_zero_ether_addr(mac)) {
2774+
vf->pf_set_mac = false;
2775+
dev_info(&pf->pdev->dev, "Removing MAC on VF %d\n", vf_id);
2776+
} else {
2777+
vf->pf_set_mac = true;
2778+
dev_info(&pf->pdev->dev, "Setting MAC %pM on VF %d\n",
2779+
mac, vf_id);
2780+
}
2781+
27762782
/* Force the VF driver stop so it has to reload with new MAC address */
27772783
i40e_vc_disable_vf(pf, vf);
27782784
dev_info(&pf->pdev->dev, "Reload the VF driver to make this change effective.\n");

drivers/net/ethernet/intel/i40evf/i40e_osdep.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct i40e_dma_mem {
5454
void *va;
5555
dma_addr_t pa;
5656
u32 size;
57-
} __packed;
57+
};
5858

5959
#define i40e_allocate_dma_mem(h, m, unused, s, a) \
6060
i40evf_allocate_dma_mem_d(h, m, s, a)
@@ -63,7 +63,7 @@ struct i40e_dma_mem {
6363
struct i40e_virt_mem {
6464
void *va;
6565
u32 size;
66-
} __packed;
66+
};
6767
#define i40e_allocate_virt_mem(h, m, s) i40evf_allocate_virt_mem_d(h, m, s)
6868
#define i40e_free_virt_mem(h, m) i40evf_free_virt_mem_d(h, m)
6969

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
275275
netdev_tx_completed_queue(txring_txq(tx_ring),
276276
total_packets, total_bytes);
277277

278-
#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)
278+
#define TX_WAKE_THRESHOLD ((s16)(DESC_NEEDED * 2))
279279
if (unlikely(total_packets && netif_carrier_ok(tx_ring->netdev) &&
280280
(I40E_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD))) {
281281
/* Make sure that anybody stopping the queue after this
@@ -1299,7 +1299,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
12991299
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
13001300
bool failure = false;
13011301

1302-
while (likely(total_rx_packets < budget)) {
1302+
while (likely(total_rx_packets < (unsigned int)budget)) {
13031303
struct i40e_rx_buffer *rx_buffer;
13041304
union i40e_rx_desc *rx_desc;
13051305
unsigned int size;
@@ -1406,7 +1406,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
14061406
rx_ring->q_vector->rx.total_bytes += total_rx_bytes;
14071407

14081408
/* guarantee a trip back through this routine if there was a failure */
1409-
return failure ? budget : total_rx_packets;
1409+
return failure ? budget : (int)total_rx_packets;
14101410
}
14111411

14121412
static u32 i40e_buildreg_itr(const int type, const u16 itr)

drivers/net/ethernet/intel/i40evf/i40evf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
#include <linux/tcp.h>
4040
#include <linux/sctp.h>
4141
#include <linux/ipv6.h>
42+
#include <linux/kernel.h>
43+
#include <linux/bitops.h>
44+
#include <linux/timer.h>
45+
#include <linux/workqueue.h>
46+
#include <linux/delay.h>
47+
#include <linux/gfp.h>
48+
#include <linux/skbuff.h>
49+
#include <linux/dma-mapping.h>
50+
#include <linux/etherdevice.h>
51+
#include <linux/socket.h>
52+
#include <linux/jiffies.h>
4253
#include <net/ip6_checksum.h>
4354
#include <net/udp.h>
4455

drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void i40evf_get_ethtool_stats(struct net_device *netdev,
165165
struct ethtool_stats *stats, u64 *data)
166166
{
167167
struct i40evf_adapter *adapter = netdev_priv(netdev);
168-
int i, j;
168+
unsigned int i, j;
169169
char *p;
170170

171171
for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) {
@@ -197,7 +197,7 @@ static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
197197
int i;
198198

199199
if (sset == ETH_SS_STATS) {
200-
for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) {
200+
for (i = 0; i < (int)I40EVF_GLOBAL_STATS_LEN; i++) {
201201
memcpy(p, i40evf_gstrings_stats[i].stat_string,
202202
ETH_GSTRING_LEN);
203203
p += ETH_GSTRING_LEN;

drivers/net/ethernet/intel/i40evf/i40evf_main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,8 @@ static void i40evf_adminq_task(struct work_struct *work)
19571957
container_of(work, struct i40evf_adapter, adminq_task);
19581958
struct i40e_hw *hw = &adapter->hw;
19591959
struct i40e_arq_event_info event;
1960-
struct virtchnl_msg *v_msg;
1961-
i40e_status ret;
1960+
enum virtchnl_ops v_op;
1961+
i40e_status ret, v_ret;
19621962
u32 val, oldval;
19631963
u16 pending;
19641964

@@ -1970,15 +1970,15 @@ static void i40evf_adminq_task(struct work_struct *work)
19701970
if (!event.msg_buf)
19711971
goto out;
19721972

1973-
v_msg = (struct virtchnl_msg *)&event.desc;
19741973
do {
19751974
ret = i40evf_clean_arq_element(hw, &event, &pending);
1976-
if (ret || !v_msg->v_opcode)
1975+
v_op = (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
1976+
v_ret = (i40e_status)le32_to_cpu(event.desc.cookie_low);
1977+
1978+
if (ret || !v_op)
19771979
break; /* No event to process or error cleaning ARQ */
19781980

1979-
i40evf_virtchnl_completion(adapter, v_msg->v_opcode,
1980-
(i40e_status)v_msg->v_retval,
1981-
event.msg_buf,
1981+
i40evf_virtchnl_completion(adapter, v_op, v_ret, event.msg_buf,
19821982
event.msg_len);
19831983
if (pending != 0)
19841984
memset(event.msg_buf, 0, I40EVF_MAX_AQ_BUF_SIZE);

0 commit comments

Comments
 (0)