Skip to content

Commit c08eeba

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue
Jeff Kirsher says: ==================== Intel Wired LAN Driver Fixes 2018-08-23 This series contains bug fixes to the ice driver. Anirudh provides several fixes, starting with static analysis fixes by replacing a bitwise-and with a constant value and replace "magic" numbers with defines. Fixed the control queue processing by removing unnecessary read/writes to registers, as well as getting a accurate value for "pending". Added additional checks to avoid NULL pointer dereferences. Fixed up code formatting issues, by cleaning up code comments and coding style. Bruce cleans up a duplicate check for owner, within the same function. Also cleans up interrupt causes that are not handled or applicable. Fix checkpatch warning about the use of bool in structures due to the wasted space and size of bool, so convert struct members to u8 instead. Jake fixes a number of potential bugs in the reporting of stats via ethtool, by simply reporting all the queue statistics, even for the queues that are not activated. Fixed a compiler warning, as well as make the code a bit cleaner but just using order_base_2() for calculating the power-of-2. Preethi adds a check to avoid a NULL pointer dereference crash during initialization. Brett clarifies the code when it comes to port VLANs and regular VLANs, by renaming defines and field values to match their intended use and purpose. Jesse initializes a variable to avoid garbage values being returned to the caller. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 0d092f0 + 3968540 commit c08eeba

File tree

14 files changed

+185
-126
lines changed

14 files changed

+185
-126
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ extern const char ice_drv_ver[];
8989
#define ice_for_each_rxq(vsi, i) \
9090
for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
9191

92+
/* Macros for each allocated tx/rx ring whether used or not in a VSI */
93+
#define ice_for_each_alloc_txq(vsi, i) \
94+
for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
95+
96+
#define ice_for_each_alloc_rxq(vsi, i) \
97+
for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
98+
9299
struct ice_tc_info {
93100
u16 qoffset;
94101
u16 qcount;
@@ -189,9 +196,9 @@ struct ice_vsi {
189196
struct list_head tmp_sync_list; /* MAC filters to be synced */
190197
struct list_head tmp_unsync_list; /* MAC filters to be unsynced */
191198

192-
bool irqs_ready;
193-
bool current_isup; /* Sync 'link up' logging */
194-
bool stat_offsets_loaded;
199+
u8 irqs_ready;
200+
u8 current_isup; /* Sync 'link up' logging */
201+
u8 stat_offsets_loaded;
195202

196203
/* queue information */
197204
u8 tx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
@@ -262,7 +269,7 @@ struct ice_pf {
262269
struct ice_hw_port_stats stats;
263270
struct ice_hw_port_stats stats_prev;
264271
struct ice_hw hw;
265-
bool stat_prev_loaded; /* has previous stats been loaded */
272+
u8 stat_prev_loaded; /* has previous stats been loaded */
266273
char int_name[ICE_INT_NAME_STR_LEN];
267274
};
268275

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,19 @@ struct ice_aqc_vsi_props {
329329
/* VLAN section */
330330
__le16 pvid; /* VLANS include priority bits */
331331
u8 pvlan_reserved[2];
332-
u8 port_vlan_flags;
333-
#define ICE_AQ_VSI_PVLAN_MODE_S 0
334-
#define ICE_AQ_VSI_PVLAN_MODE_M (0x3 << ICE_AQ_VSI_PVLAN_MODE_S)
335-
#define ICE_AQ_VSI_PVLAN_MODE_UNTAGGED 0x1
336-
#define ICE_AQ_VSI_PVLAN_MODE_TAGGED 0x2
337-
#define ICE_AQ_VSI_PVLAN_MODE_ALL 0x3
332+
u8 vlan_flags;
333+
#define ICE_AQ_VSI_VLAN_MODE_S 0
334+
#define ICE_AQ_VSI_VLAN_MODE_M (0x3 << ICE_AQ_VSI_VLAN_MODE_S)
335+
#define ICE_AQ_VSI_VLAN_MODE_UNTAGGED 0x1
336+
#define ICE_AQ_VSI_VLAN_MODE_TAGGED 0x2
337+
#define ICE_AQ_VSI_VLAN_MODE_ALL 0x3
338338
#define ICE_AQ_VSI_PVLAN_INSERT_PVID BIT(2)
339-
#define ICE_AQ_VSI_PVLAN_EMOD_S 3
340-
#define ICE_AQ_VSI_PVLAN_EMOD_M (0x3 << ICE_AQ_VSI_PVLAN_EMOD_S)
341-
#define ICE_AQ_VSI_PVLAN_EMOD_STR_BOTH (0x0 << ICE_AQ_VSI_PVLAN_EMOD_S)
342-
#define ICE_AQ_VSI_PVLAN_EMOD_STR_UP (0x1 << ICE_AQ_VSI_PVLAN_EMOD_S)
343-
#define ICE_AQ_VSI_PVLAN_EMOD_STR (0x2 << ICE_AQ_VSI_PVLAN_EMOD_S)
344-
#define ICE_AQ_VSI_PVLAN_EMOD_NOTHING (0x3 << ICE_AQ_VSI_PVLAN_EMOD_S)
339+
#define ICE_AQ_VSI_VLAN_EMOD_S 3
340+
#define ICE_AQ_VSI_VLAN_EMOD_M (0x3 << ICE_AQ_VSI_VLAN_EMOD_S)
341+
#define ICE_AQ_VSI_VLAN_EMOD_STR_BOTH (0x0 << ICE_AQ_VSI_VLAN_EMOD_S)
342+
#define ICE_AQ_VSI_VLAN_EMOD_STR_UP (0x1 << ICE_AQ_VSI_VLAN_EMOD_S)
343+
#define ICE_AQ_VSI_VLAN_EMOD_STR (0x2 << ICE_AQ_VSI_VLAN_EMOD_S)
344+
#define ICE_AQ_VSI_VLAN_EMOD_NOTHING (0x3 << ICE_AQ_VSI_VLAN_EMOD_S)
345345
u8 pvlan_reserved2[3];
346346
/* ingress egress up sections */
347347
__le32 ingress_table; /* bitmap, 3 bits per up */
@@ -594,6 +594,7 @@ struct ice_sw_rule_lg_act {
594594
#define ICE_LG_ACT_GENERIC_OFFSET_M (0x7 << ICE_LG_ACT_GENERIC_OFFSET_S)
595595
#define ICE_LG_ACT_GENERIC_PRIORITY_S 22
596596
#define ICE_LG_ACT_GENERIC_PRIORITY_M (0x7 << ICE_LG_ACT_GENERIC_PRIORITY_S)
597+
#define ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX 7
597598

598599
/* Action = 7 - Set Stat count */
599600
#define ICE_LG_ACT_STAT_COUNT 0x7

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static enum ice_status ice_set_mac_type(struct ice_hw *hw)
4545
/**
4646
* ice_clear_pf_cfg - Clear PF configuration
4747
* @hw: pointer to the hardware structure
48+
*
49+
* Clears any existing PF configuration (VSIs, VSI lists, switch rules, port
50+
* configuration, flow director filters, etc.).
4851
*/
4952
enum ice_status ice_clear_pf_cfg(struct ice_hw *hw)
5053
{
@@ -1483,7 +1486,7 @@ enum ice_status ice_get_link_status(struct ice_port_info *pi, bool *link_up)
14831486
struct ice_phy_info *phy_info;
14841487
enum ice_status status = 0;
14851488

1486-
if (!pi)
1489+
if (!pi || !link_up)
14871490
return ICE_ERR_PARAM;
14881491

14891492
phy_info = &pi->phy;
@@ -1619,20 +1622,23 @@ __ice_aq_get_set_rss_lut(struct ice_hw *hw, u16 vsi_id, u8 lut_type, u8 *lut,
16191622
}
16201623

16211624
/* LUT size is only valid for Global and PF table types */
1622-
if (lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128) {
1623-
flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128_FLAG <<
1624-
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
1625-
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
1626-
} else if (lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512) {
1625+
switch (lut_size) {
1626+
case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128:
1627+
break;
1628+
case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512:
16271629
flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512_FLAG <<
16281630
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
16291631
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
1630-
} else if ((lut_size == ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K) &&
1631-
(lut_type == ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF)) {
1632-
flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K_FLAG <<
1633-
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
1634-
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
1635-
} else {
1632+
break;
1633+
case ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K:
1634+
if (lut_type == ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF) {
1635+
flags |= (ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K_FLAG <<
1636+
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_S) &
1637+
ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_M;
1638+
break;
1639+
}
1640+
/* fall-through */
1641+
default:
16361642
status = ICE_ERR_PARAM;
16371643
goto ice_aq_get_set_rss_lut_exit;
16381644
}

drivers/net/ethernet/intel/ice/ice_controlq.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,14 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
597597
return 0;
598598

599599
init_ctrlq_free_rq:
600-
ice_shutdown_rq(hw, cq);
601-
ice_shutdown_sq(hw, cq);
602-
mutex_destroy(&cq->sq_lock);
603-
mutex_destroy(&cq->rq_lock);
600+
if (cq->rq.head) {
601+
ice_shutdown_rq(hw, cq);
602+
mutex_destroy(&cq->rq_lock);
603+
}
604+
if (cq->sq.head) {
605+
ice_shutdown_sq(hw, cq);
606+
mutex_destroy(&cq->sq_lock);
607+
}
604608
return status;
605609
}
606610

@@ -706,10 +710,14 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
706710
return;
707711
}
708712

709-
ice_shutdown_sq(hw, cq);
710-
ice_shutdown_rq(hw, cq);
711-
mutex_destroy(&cq->sq_lock);
712-
mutex_destroy(&cq->rq_lock);
713+
if (cq->sq.head) {
714+
ice_shutdown_sq(hw, cq);
715+
mutex_destroy(&cq->sq_lock);
716+
}
717+
if (cq->rq.head) {
718+
ice_shutdown_rq(hw, cq);
719+
mutex_destroy(&cq->rq_lock);
720+
}
713721
}
714722

715723
/**
@@ -1057,8 +1065,11 @@ ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
10571065

10581066
clean_rq_elem_out:
10591067
/* Set pending if needed, unlock and return */
1060-
if (pending)
1068+
if (pending) {
1069+
/* re-read HW head to calculate actual pending messages */
1070+
ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask);
10611071
*pending = (u16)((ntc > ntu ? cq->rq.count : 0) + (ntu - ntc));
1072+
}
10621073
clean_rq_elem_err:
10631074
mutex_unlock(&cq->rq_lock);
10641075

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int ice_q_stats_len(struct net_device *netdev)
2626
{
2727
struct ice_netdev_priv *np = netdev_priv(netdev);
2828

29-
return ((np->vsi->num_txq + np->vsi->num_rxq) *
29+
return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) *
3030
(sizeof(struct ice_q_stats) / sizeof(u64)));
3131
}
3232

@@ -218,15 +218,15 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
218218
p += ETH_GSTRING_LEN;
219219
}
220220

221-
ice_for_each_txq(vsi, i) {
221+
ice_for_each_alloc_txq(vsi, i) {
222222
snprintf(p, ETH_GSTRING_LEN,
223223
"tx-queue-%u.tx_packets", i);
224224
p += ETH_GSTRING_LEN;
225225
snprintf(p, ETH_GSTRING_LEN, "tx-queue-%u.tx_bytes", i);
226226
p += ETH_GSTRING_LEN;
227227
}
228228

229-
ice_for_each_rxq(vsi, i) {
229+
ice_for_each_alloc_rxq(vsi, i) {
230230
snprintf(p, ETH_GSTRING_LEN,
231231
"rx-queue-%u.rx_packets", i);
232232
p += ETH_GSTRING_LEN;
@@ -253,6 +253,24 @@ static int ice_get_sset_count(struct net_device *netdev, int sset)
253253
{
254254
switch (sset) {
255255
case ETH_SS_STATS:
256+
/* The number (and order) of strings reported *must* remain
257+
* constant for a given netdevice. This function must not
258+
* report a different number based on run time parameters
259+
* (such as the number of queues in use, or the setting of
260+
* a private ethtool flag). This is due to the nature of the
261+
* ethtool stats API.
262+
*
263+
* User space programs such as ethtool must make 3 separate
264+
* ioctl requests, one for size, one for the strings, and
265+
* finally one for the stats. Since these cross into
266+
* user space, changes to the number or size could result in
267+
* undefined memory access or incorrect string<->value
268+
* correlations for statistics.
269+
*
270+
* Even if it appears to be safe, changes to the size or
271+
* order of strings will suffer from race conditions and are
272+
* not safe.
273+
*/
256274
return ICE_ALL_STATS_LEN(netdev);
257275
default:
258276
return -EOPNOTSUPP;
@@ -280,18 +298,26 @@ ice_get_ethtool_stats(struct net_device *netdev,
280298
/* populate per queue stats */
281299
rcu_read_lock();
282300

283-
ice_for_each_txq(vsi, j) {
301+
ice_for_each_alloc_txq(vsi, j) {
284302
ring = READ_ONCE(vsi->tx_rings[j]);
285-
if (!ring)
286-
continue;
287-
data[i++] = ring->stats.pkts;
288-
data[i++] = ring->stats.bytes;
303+
if (ring) {
304+
data[i++] = ring->stats.pkts;
305+
data[i++] = ring->stats.bytes;
306+
} else {
307+
data[i++] = 0;
308+
data[i++] = 0;
309+
}
289310
}
290311

291-
ice_for_each_rxq(vsi, j) {
312+
ice_for_each_alloc_rxq(vsi, j) {
292313
ring = READ_ONCE(vsi->rx_rings[j]);
293-
data[i++] = ring->stats.pkts;
294-
data[i++] = ring->stats.bytes;
314+
if (ring) {
315+
data[i++] = ring->stats.pkts;
316+
data[i++] = ring->stats.bytes;
317+
} else {
318+
data[i++] = 0;
319+
data[i++] = 0;
320+
}
295321
}
296322

297323
rcu_read_unlock();
@@ -519,7 +545,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
519545
goto done;
520546
}
521547

522-
for (i = 0; i < vsi->num_txq; i++) {
548+
for (i = 0; i < vsi->alloc_txq; i++) {
523549
/* clone ring and setup updated count */
524550
tx_rings[i] = *vsi->tx_rings[i];
525551
tx_rings[i].count = new_tx_cnt;
@@ -551,7 +577,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
551577
goto done;
552578
}
553579

554-
for (i = 0; i < vsi->num_rxq; i++) {
580+
for (i = 0; i < vsi->alloc_rxq; i++) {
555581
/* clone ring and setup updated count */
556582
rx_rings[i] = *vsi->rx_rings[i];
557583
rx_rings[i].count = new_rx_cnt;

drivers/net/ethernet/intel/ice/ice_hw_autogen.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@
121121
#define PFINT_FW_CTL_CAUSE_ENA_S 30
122122
#define PFINT_FW_CTL_CAUSE_ENA_M BIT(PFINT_FW_CTL_CAUSE_ENA_S)
123123
#define PFINT_OICR 0x0016CA00
124-
#define PFINT_OICR_HLP_RDY_S 14
125-
#define PFINT_OICR_HLP_RDY_M BIT(PFINT_OICR_HLP_RDY_S)
126-
#define PFINT_OICR_CPM_RDY_S 15
127-
#define PFINT_OICR_CPM_RDY_M BIT(PFINT_OICR_CPM_RDY_S)
128124
#define PFINT_OICR_ECC_ERR_S 16
129125
#define PFINT_OICR_ECC_ERR_M BIT(PFINT_OICR_ECC_ERR_S)
130126
#define PFINT_OICR_MAL_DETECT_S 19
@@ -133,10 +129,6 @@
133129
#define PFINT_OICR_GRST_M BIT(PFINT_OICR_GRST_S)
134130
#define PFINT_OICR_PCI_EXCEPTION_S 21
135131
#define PFINT_OICR_PCI_EXCEPTION_M BIT(PFINT_OICR_PCI_EXCEPTION_S)
136-
#define PFINT_OICR_GPIO_S 22
137-
#define PFINT_OICR_GPIO_M BIT(PFINT_OICR_GPIO_S)
138-
#define PFINT_OICR_STORM_DETECT_S 24
139-
#define PFINT_OICR_STORM_DETECT_M BIT(PFINT_OICR_STORM_DETECT_S)
140132
#define PFINT_OICR_HMC_ERR_S 26
141133
#define PFINT_OICR_HMC_ERR_M BIT(PFINT_OICR_HMC_ERR_S)
142134
#define PFINT_OICR_PE_CRITERR_S 28

drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ enum ice_rx_flex_desc_status_error_0_bits {
265265
struct ice_rlan_ctx {
266266
u16 head;
267267
u16 cpuid; /* bigger than needed, see above for reason */
268+
#define ICE_RLAN_BASE_S 7
268269
u64 base;
269270
u16 qlen;
270271
#define ICE_RLAN_CTX_DBUF_S 7

0 commit comments

Comments
 (0)