Skip to content

Commit af14827

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 100GbE Intel Wired LAN Driver Updates 2017-10-03 This series contains updates to fm10k only. Jake provides majority of the changes in this series, starting with using fm10k_prepare_for_reset() if we lose PCIe link. Before we would detach the device and close the netdev, which left a lot of items still active, such as the Tx/Rx resources. This could cause problems where register reads would return potentially invalid values and would result in unknown driver behavior, so call fm10k_prepare_for_reset() much like we do for suspend/resume cycles. This will attempt to shutdown as much as possible to prevent possible issues. Then replaced the PCI specific legacy power management hooks with the new generic power management hooks for both suspend and hibernate. Introduced a workqueue item which monitors a queue of MAC and VLAN requests since a large number of MAC address or VLAN updates at once can overload the mailbox with too many messages at once. Fixed a cppcheck warning by properly declaring the min_rate and max_rate variables in the declaration and definition for .ndo_set_vf_bw, rather than using "unused" for the minimum rates. Joe Perches fixes the backward logic when using net_ratelimit(). ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6c55700 + 3e256ac commit af14827

File tree

7 files changed

+665
-137
lines changed

7 files changed

+665
-137
lines changed

drivers/net/ethernet/intel/fm10k/fm10k.h

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,29 @@ struct fm10k_udp_port {
248248
__be16 port;
249249
};
250250

251+
enum fm10k_macvlan_request_type {
252+
FM10K_UC_MAC_REQUEST,
253+
FM10K_MC_MAC_REQUEST,
254+
FM10K_VLAN_REQUEST
255+
};
256+
257+
struct fm10k_macvlan_request {
258+
enum fm10k_macvlan_request_type type;
259+
struct list_head list;
260+
union {
261+
struct fm10k_mac_request {
262+
u8 addr[ETH_ALEN];
263+
u16 glort;
264+
u16 vid;
265+
} mac;
266+
struct fm10k_vlan_request {
267+
u32 vid;
268+
u8 vsi;
269+
} vlan;
270+
};
271+
bool set;
272+
};
273+
251274
/* one work queue for entire driver */
252275
extern struct workqueue_struct *fm10k_workqueue;
253276

@@ -270,11 +293,15 @@ enum fm10k_flags_t {
270293

271294
enum fm10k_state_t {
272295
__FM10K_RESETTING,
296+
__FM10K_RESET_DETACHED,
297+
__FM10K_RESET_SUSPENDED,
273298
__FM10K_DOWN,
274299
__FM10K_SERVICE_SCHED,
275300
__FM10K_SERVICE_REQUEST,
276301
__FM10K_SERVICE_DISABLE,
277-
__FM10K_MBX_LOCK,
302+
__FM10K_MACVLAN_SCHED,
303+
__FM10K_MACVLAN_REQUEST,
304+
__FM10K_MACVLAN_DISABLE,
278305
__FM10K_LINK_DOWN,
279306
__FM10K_UPDATING_STATS,
280307
/* This value must be last and determines the BITMAP size */
@@ -344,6 +371,8 @@ struct fm10k_intfc {
344371

345372
struct fm10k_hw_stats stats;
346373
struct fm10k_hw hw;
374+
/* Mailbox lock */
375+
spinlock_t mbx_lock;
347376
u32 __iomem *uc_addr;
348377
u32 __iomem *sw_addr;
349378
u16 msg_enable;
@@ -365,6 +394,12 @@ struct fm10k_intfc {
365394
struct list_head vxlan_port;
366395
struct list_head geneve_port;
367396

397+
/* MAC/VLAN update queue */
398+
struct list_head macvlan_requests;
399+
struct delayed_work macvlan_task;
400+
/* MAC/VLAN update queue lock */
401+
spinlock_t macvlan_lock;
402+
368403
#ifdef CONFIG_DEBUG_FS
369404
struct dentry *dbg_intfc;
370405
#endif /* CONFIG_DEBUG_FS */
@@ -384,23 +419,17 @@ struct fm10k_intfc {
384419

385420
static inline void fm10k_mbx_lock(struct fm10k_intfc *interface)
386421
{
387-
/* busy loop if we cannot obtain the lock as some calls
388-
* such as ndo_set_rx_mode may be made in atomic context
389-
*/
390-
while (test_and_set_bit(__FM10K_MBX_LOCK, interface->state))
391-
udelay(20);
422+
spin_lock(&interface->mbx_lock);
392423
}
393424

394425
static inline void fm10k_mbx_unlock(struct fm10k_intfc *interface)
395426
{
396-
/* flush memory to make sure state is correct */
397-
smp_mb__before_atomic();
398-
clear_bit(__FM10K_MBX_LOCK, interface->state);
427+
spin_unlock(&interface->mbx_lock);
399428
}
400429

401430
static inline int fm10k_mbx_trylock(struct fm10k_intfc *interface)
402431
{
403-
return !test_and_set_bit(__FM10K_MBX_LOCK, interface->state);
432+
return spin_trylock(&interface->mbx_lock);
404433
}
405434

406435
/* fm10k_test_staterr - test bits in Rx descriptor status and error fields */
@@ -490,6 +519,7 @@ void fm10k_up(struct fm10k_intfc *interface);
490519
void fm10k_down(struct fm10k_intfc *interface);
491520
void fm10k_update_stats(struct fm10k_intfc *interface);
492521
void fm10k_service_event_schedule(struct fm10k_intfc *interface);
522+
void fm10k_macvlan_schedule(struct fm10k_intfc *interface);
493523
void fm10k_update_rx_drop_en(struct fm10k_intfc *interface);
494524
#ifdef CONFIG_NET_POLL_CONTROLLER
495525
void fm10k_netpoll(struct net_device *netdev);
@@ -510,6 +540,12 @@ void fm10k_reset_rx_state(struct fm10k_intfc *);
510540
int fm10k_setup_tc(struct net_device *dev, u8 tc);
511541
int fm10k_open(struct net_device *netdev);
512542
int fm10k_close(struct net_device *netdev);
543+
int fm10k_queue_vlan_request(struct fm10k_intfc *interface, u32 vid,
544+
u8 vsi, bool set);
545+
int fm10k_queue_mac_request(struct fm10k_intfc *interface, u16 glort,
546+
const unsigned char *addr, u16 vid, bool set);
547+
void fm10k_clear_macvlan_queue(struct fm10k_intfc *interface,
548+
u16 glort, bool vlans);
513549

514550
/* Ethtool */
515551
void fm10k_set_ethtool_ops(struct net_device *dev);
@@ -526,8 +562,8 @@ s32 fm10k_iov_update_pvid(struct fm10k_intfc *interface, u16 glort, u16 pvid);
526562
int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac);
527563
int fm10k_ndo_set_vf_vlan(struct net_device *netdev,
528564
int vf_idx, u16 vid, u8 qos, __be16 vlan_proto);
529-
int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx, int rate,
530-
int unused);
565+
int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx,
566+
int __always_unused min_rate, int max_rate);
531567
int fm10k_ndo_get_vf_config(struct net_device *netdev,
532568
int vf_idx, struct ifla_vf_info *ivi);
533569

drivers/net/ethernet/intel/fm10k/fm10k_iov.c

Lines changed: 135 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,133 @@ static s32 fm10k_iov_msg_error(struct fm10k_hw *hw, u32 **results,
3535
return fm10k_tlv_msg_error(hw, results, mbx);
3636
}
3737

38+
/**
39+
* fm10k_iov_msg_queue_mac_vlan - Message handler for MAC/VLAN request from VF
40+
* @hw: Pointer to hardware structure
41+
* @results: Pointer array to message, results[0] is pointer to message
42+
* @mbx: Pointer to mailbox information structure
43+
*
44+
* This function is a custom handler for MAC/VLAN requests from the VF. The
45+
* assumption is that it is acceptable to directly hand off the message from
46+
* the VF to the PF's switch manager. However, we use a MAC/VLAN message
47+
* queue to avoid overloading the mailbox when a large number of requests
48+
* come in.
49+
**/
50+
static s32 fm10k_iov_msg_queue_mac_vlan(struct fm10k_hw *hw, u32 **results,
51+
struct fm10k_mbx_info *mbx)
52+
{
53+
struct fm10k_vf_info *vf_info = (struct fm10k_vf_info *)mbx;
54+
struct fm10k_intfc *interface = hw->back;
55+
u8 mac[ETH_ALEN];
56+
u32 *result;
57+
int err = 0;
58+
bool set;
59+
u16 vlan;
60+
u32 vid;
61+
62+
/* we shouldn't be updating rules on a disabled interface */
63+
if (!FM10K_VF_FLAG_ENABLED(vf_info))
64+
err = FM10K_ERR_PARAM;
65+
66+
if (!err && !!results[FM10K_MAC_VLAN_MSG_VLAN]) {
67+
result = results[FM10K_MAC_VLAN_MSG_VLAN];
68+
69+
/* record VLAN id requested */
70+
err = fm10k_tlv_attr_get_u32(result, &vid);
71+
if (err)
72+
return err;
73+
74+
set = !(vid & FM10K_VLAN_CLEAR);
75+
vid &= ~FM10K_VLAN_CLEAR;
76+
77+
/* if the length field has been set, this is a multi-bit
78+
* update request. For multi-bit requests, simply disallow
79+
* them when the pf_vid has been set. In this case, the PF
80+
* should have already cleared the VLAN_TABLE, and if we
81+
* allowed them, it could allow a rogue VF to receive traffic
82+
* on a VLAN it was not assigned. In the single-bit case, we
83+
* need to modify requests for VLAN 0 to use the default PF or
84+
* SW vid when assigned.
85+
*/
86+
87+
if (vid >> 16) {
88+
/* prevent multi-bit requests when PF has
89+
* administratively set the VLAN for this VF
90+
*/
91+
if (vf_info->pf_vid)
92+
return FM10K_ERR_PARAM;
93+
} else {
94+
err = fm10k_iov_select_vid(vf_info, (u16)vid);
95+
if (err < 0)
96+
return err;
97+
98+
vid = err;
99+
}
100+
101+
/* update VSI info for VF in regards to VLAN table */
102+
err = hw->mac.ops.update_vlan(hw, vid, vf_info->vsi, set);
103+
}
104+
105+
if (!err && !!results[FM10K_MAC_VLAN_MSG_MAC]) {
106+
result = results[FM10K_MAC_VLAN_MSG_MAC];
107+
108+
/* record unicast MAC address requested */
109+
err = fm10k_tlv_attr_get_mac_vlan(result, mac, &vlan);
110+
if (err)
111+
return err;
112+
113+
/* block attempts to set MAC for a locked device */
114+
if (is_valid_ether_addr(vf_info->mac) &&
115+
!ether_addr_equal(mac, vf_info->mac))
116+
return FM10K_ERR_PARAM;
117+
118+
set = !(vlan & FM10K_VLAN_CLEAR);
119+
vlan &= ~FM10K_VLAN_CLEAR;
120+
121+
err = fm10k_iov_select_vid(vf_info, vlan);
122+
if (err < 0)
123+
return err;
124+
125+
vlan = (u16)err;
126+
127+
/* Add this request to the MAC/VLAN queue */
128+
err = fm10k_queue_mac_request(interface, vf_info->glort,
129+
mac, vlan, set);
130+
}
131+
132+
if (!err && !!results[FM10K_MAC_VLAN_MSG_MULTICAST]) {
133+
result = results[FM10K_MAC_VLAN_MSG_MULTICAST];
134+
135+
/* record multicast MAC address requested */
136+
err = fm10k_tlv_attr_get_mac_vlan(result, mac, &vlan);
137+
if (err)
138+
return err;
139+
140+
/* verify that the VF is allowed to request multicast */
141+
if (!(vf_info->vf_flags & FM10K_VF_FLAG_MULTI_ENABLED))
142+
return FM10K_ERR_PARAM;
143+
144+
set = !(vlan & FM10K_VLAN_CLEAR);
145+
vlan &= ~FM10K_VLAN_CLEAR;
146+
147+
err = fm10k_iov_select_vid(vf_info, vlan);
148+
if (err < 0)
149+
return err;
150+
151+
vlan = (u16)err;
152+
153+
/* Add this request to the MAC/VLAN queue */
154+
err = fm10k_queue_mac_request(interface, vf_info->glort,
155+
mac, vlan, set);
156+
}
157+
158+
return err;
159+
}
160+
38161
static const struct fm10k_msg_data iov_mbx_data[] = {
39162
FM10K_TLV_MSG_TEST_HANDLER(fm10k_tlv_msg_test),
40163
FM10K_VF_MSG_MSIX_HANDLER(fm10k_iov_msg_msix_pf),
41-
FM10K_VF_MSG_MAC_VLAN_HANDLER(fm10k_iov_msg_mac_vlan_pf),
164+
FM10K_VF_MSG_MAC_VLAN_HANDLER(fm10k_iov_msg_queue_mac_vlan),
42165
FM10K_VF_MSG_LPORT_STATE_HANDLER(fm10k_iov_msg_lport_state_pf),
43166
FM10K_TLV_MSG_ERROR_HANDLER(fm10k_iov_msg_error),
44167
};
@@ -126,8 +249,10 @@ s32 fm10k_iov_mbx(struct fm10k_intfc *interface)
126249
hw->mbx.ops.process(hw, &hw->mbx);
127250

128251
/* verify port mapping is valid, if not reset port */
129-
if (vf_info->vf_flags && !fm10k_glort_valid_pf(hw, glort))
252+
if (vf_info->vf_flags && !fm10k_glort_valid_pf(hw, glort)) {
130253
hw->iov.ops.reset_lport(hw, vf_info);
254+
fm10k_clear_macvlan_queue(interface, glort, false);
255+
}
131256

132257
/* reset VFs that have mailbox timed out */
133258
if (!mbx->timeout) {
@@ -190,6 +315,7 @@ void fm10k_iov_suspend(struct pci_dev *pdev)
190315

191316
hw->iov.ops.reset_resources(hw, vf_info);
192317
hw->iov.ops.reset_lport(hw, vf_info);
318+
fm10k_clear_macvlan_queue(interface, vf_info->glort, false);
193319
}
194320
}
195321

@@ -414,6 +540,8 @@ static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface,
414540
/* disable LPORT for this VF which clears switch rules */
415541
hw->iov.ops.reset_lport(hw, vf_info);
416542

543+
fm10k_clear_macvlan_queue(interface, vf_info->glort, false);
544+
417545
/* assign new MAC+VLAN for this VF */
418546
hw->iov.ops.assign_default_mac_vlan(hw, vf_info);
419547

@@ -485,7 +613,7 @@ int fm10k_ndo_set_vf_vlan(struct net_device *netdev, int vf_idx, u16 vid,
485613
}
486614

487615
int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx,
488-
int __always_unused unused, int rate)
616+
int __always_unused min_rate, int max_rate)
489617
{
490618
struct fm10k_intfc *interface = netdev_priv(netdev);
491619
struct fm10k_iov_data *iov_data = interface->iov_data;
@@ -496,14 +624,15 @@ int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx,
496624
return -EINVAL;
497625

498626
/* rate limit cannot be less than 10Mbs or greater than link speed */
499-
if (rate && ((rate < FM10K_VF_TC_MIN) || rate > FM10K_VF_TC_MAX))
627+
if (max_rate &&
628+
(max_rate < FM10K_VF_TC_MIN || max_rate > FM10K_VF_TC_MAX))
500629
return -EINVAL;
501630

502631
/* store values */
503-
iov_data->vf_info[vf_idx].rate = rate;
632+
iov_data->vf_info[vf_idx].rate = max_rate;
504633

505634
/* update hardware configuration */
506-
hw->iov.ops.configure_tc(hw, vf_idx, rate);
635+
hw->iov.ops.configure_tc(hw, vf_idx, max_rate);
507636

508637
return 0;
509638
}

drivers/net/ethernet/intel/fm10k/fm10k_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "fm10k.h"
3030

31-
#define DRV_VERSION "0.21.7-k"
31+
#define DRV_VERSION "0.22.1-k"
3232
#define DRV_SUMMARY "Intel(R) Ethernet Switch Host Interface Driver"
3333
const char fm10k_driver_version[] = DRV_VERSION;
3434
char fm10k_driver_name[] = "fm10k";
@@ -806,9 +806,10 @@ static int fm10k_tso(struct fm10k_ring *tx_ring,
806806
tx_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
807807

808808
return 1;
809+
809810
err_vxlan:
810811
tx_ring->netdev->features &= ~NETIF_F_GSO_UDP_TUNNEL;
811-
if (!net_ratelimit())
812+
if (net_ratelimit())
812813
netdev_err(tx_ring->netdev,
813814
"TSO requested for unsupported tunnel, disabling offload\n");
814815
return -1;

0 commit comments

Comments
 (0)