Skip to content

Commit ec72001

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 2018-09-27 This series contains fixes to the ice driver only. Jake fixes a potential crash due to attempting to access the mutex which is already destroyed. Fix this by using rq.count and sq.count to determine if the queue was initialized. Fixed the current logic for checking the firmware version to properly handle situations when firmware major/minor versions differ and when the branch version differs. Bruce replaces a memcpy() with a direct assignment, which is preferred. Also updated the branding strings and device ids supported by the driver. Fixed the "ethtool -G" command in the driver, which was always returning EINVAL when changing the descriptor ring size. Brett update and clarified code comments. Anirudh updates the driver to ensure we query the firmware for the transmit scheduler node information before adding it to the driver database, to ensure we have the current information. Also update the "get capabilities" command to get device and function capabilities. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5362700 + f934bb9 commit ec72001

File tree

9 files changed

+150
-48
lines changed

9 files changed

+150
-48
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
extern const char ice_drv_ver[];
4040
#define ICE_BAR0 0
4141
#define ICE_DFLT_NUM_DESC 128
42-
#define ICE_MIN_NUM_DESC 8
43-
#define ICE_MAX_NUM_DESC 8160
4442
#define ICE_REQ_DESC_MULTIPLE 32
43+
#define ICE_MIN_NUM_DESC ICE_REQ_DESC_MULTIPLE
44+
#define ICE_MAX_NUM_DESC 8160
4545
#define ICE_DFLT_TRAFFIC_CLASS BIT(0)
4646
#define ICE_INT_NAME_STR_LEN (IFNAMSIZ + 16)
4747
#define ICE_ETHTOOL_FWVER_LEN 32

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ struct ice_aqc_add_elem {
736736
struct ice_aqc_txsched_elem_data generic[1];
737737
};
738738

739+
struct ice_aqc_get_elem {
740+
struct ice_aqc_txsched_elem_data generic[1];
741+
};
742+
739743
struct ice_aqc_get_topo_elem {
740744
struct ice_aqc_txsched_topo_grp_info_hdr hdr;
741745
struct ice_aqc_txsched_elem_data
@@ -1409,6 +1413,7 @@ enum ice_adminq_opc {
14091413
/* transmit scheduler commands */
14101414
ice_aqc_opc_get_dflt_topo = 0x0400,
14111415
ice_aqc_opc_add_sched_elems = 0x0401,
1416+
ice_aqc_opc_get_sched_elems = 0x0404,
14121417
ice_aqc_opc_suspend_sched_elems = 0x0409,
14131418
ice_aqc_opc_resume_sched_elems = 0x040A,
14141419
ice_aqc_opc_delete_sched_elems = 0x040F,

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

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,15 +1451,15 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
14511451
* @hw: pointer to the hw struct
14521452
* @buf: a virtual buffer to hold the capabilities
14531453
* @buf_size: Size of the virtual buffer
1454-
* @data_size: Size of the returned data, or buf size needed if AQ err==ENOMEM
1454+
* @cap_count: cap count needed if AQ err==ENOMEM
14551455
* @opc: capabilities type to discover - pass in the command opcode
14561456
* @cd: pointer to command details structure or NULL
14571457
*
14581458
* Get the function(0x000a)/device(0x000b) capabilities description from
14591459
* the firmware.
14601460
*/
14611461
static enum ice_status
1462-
ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u16 *data_size,
1462+
ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
14631463
enum ice_adminq_opc opc, struct ice_sq_cd *cd)
14641464
{
14651465
struct ice_aqc_list_caps *cmd;
@@ -1477,58 +1477,76 @@ ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u16 *data_size,
14771477
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
14781478
if (!status)
14791479
ice_parse_caps(hw, buf, le32_to_cpu(cmd->count), opc);
1480-
*data_size = le16_to_cpu(desc.datalen);
1481-
1480+
else if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOMEM)
1481+
*cap_count =
1482+
DIV_ROUND_UP(le16_to_cpu(desc.datalen),
1483+
sizeof(struct ice_aqc_list_caps_elem));
14821484
return status;
14831485
}
14841486

14851487
/**
1486-
* ice_get_caps - get info about the HW
1488+
* ice_discover_caps - get info about the HW
14871489
* @hw: pointer to the hardware structure
1490+
* @opc: capabilities type to discover - pass in the command opcode
14881491
*/
1489-
enum ice_status ice_get_caps(struct ice_hw *hw)
1492+
static enum ice_status ice_discover_caps(struct ice_hw *hw,
1493+
enum ice_adminq_opc opc)
14901494
{
14911495
enum ice_status status;
1492-
u16 data_size = 0;
1496+
u32 cap_count;
14931497
u16 cbuf_len;
14941498
u8 retries;
14951499

14961500
/* The driver doesn't know how many capabilities the device will return
14971501
* so the buffer size required isn't known ahead of time. The driver
14981502
* starts with cbuf_len and if this turns out to be insufficient, the
1499-
* device returns ICE_AQ_RC_ENOMEM and also the buffer size it needs.
1500-
* The driver then allocates the buffer of this size and retries the
1501-
* operation. So it follows that the retry count is 2.
1503+
* device returns ICE_AQ_RC_ENOMEM and also the cap_count it needs.
1504+
* The driver then allocates the buffer based on the count and retries
1505+
* the operation. So it follows that the retry count is 2.
15021506
*/
15031507
#define ICE_GET_CAP_BUF_COUNT 40
15041508
#define ICE_GET_CAP_RETRY_COUNT 2
15051509

1506-
cbuf_len = ICE_GET_CAP_BUF_COUNT *
1507-
sizeof(struct ice_aqc_list_caps_elem);
1508-
1510+
cap_count = ICE_GET_CAP_BUF_COUNT;
15091511
retries = ICE_GET_CAP_RETRY_COUNT;
15101512

15111513
do {
15121514
void *cbuf;
15131515

1516+
cbuf_len = (u16)(cap_count *
1517+
sizeof(struct ice_aqc_list_caps_elem));
15141518
cbuf = devm_kzalloc(ice_hw_to_dev(hw), cbuf_len, GFP_KERNEL);
15151519
if (!cbuf)
15161520
return ICE_ERR_NO_MEMORY;
15171521

1518-
status = ice_aq_discover_caps(hw, cbuf, cbuf_len, &data_size,
1519-
ice_aqc_opc_list_func_caps, NULL);
1522+
status = ice_aq_discover_caps(hw, cbuf, cbuf_len, &cap_count,
1523+
opc, NULL);
15201524
devm_kfree(ice_hw_to_dev(hw), cbuf);
15211525

15221526
if (!status || hw->adminq.sq_last_status != ICE_AQ_RC_ENOMEM)
15231527
break;
15241528

15251529
/* If ENOMEM is returned, try again with bigger buffer */
1526-
cbuf_len = data_size;
15271530
} while (--retries);
15281531

15291532
return status;
15301533
}
15311534

1535+
/**
1536+
* ice_get_caps - get info about the HW
1537+
* @hw: pointer to the hardware structure
1538+
*/
1539+
enum ice_status ice_get_caps(struct ice_hw *hw)
1540+
{
1541+
enum ice_status status;
1542+
1543+
status = ice_discover_caps(hw, ice_aqc_opc_list_dev_caps);
1544+
if (!status)
1545+
status = ice_discover_caps(hw, ice_aqc_opc_list_func_caps);
1546+
1547+
return status;
1548+
}
1549+
15321550
/**
15331551
* ice_aq_manage_mac_write - manage MAC address write command
15341552
* @hw: pointer to the hw struct

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -518,22 +518,31 @@ ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
518518

519519
/**
520520
* ice_aq_ver_check - Check the reported AQ API version.
521-
* @fw_branch: The "branch" of FW, typically describes the device type
522-
* @fw_major: The major version of the FW API
523-
* @fw_minor: The minor version increment of the FW API
521+
* @hw: pointer to the hardware structure
524522
*
525523
* Checks if the driver should load on a given AQ API version.
526524
*
527525
* Return: 'true' iff the driver should attempt to load. 'false' otherwise.
528526
*/
529-
static bool ice_aq_ver_check(u8 fw_branch, u8 fw_major, u8 fw_minor)
527+
static bool ice_aq_ver_check(struct ice_hw *hw)
530528
{
531-
if (fw_branch != EXP_FW_API_VER_BRANCH)
532-
return false;
533-
if (fw_major != EXP_FW_API_VER_MAJOR)
534-
return false;
535-
if (fw_minor != EXP_FW_API_VER_MINOR)
529+
if (hw->api_maj_ver > EXP_FW_API_VER_MAJOR) {
530+
/* Major API version is newer than expected, don't load */
531+
dev_warn(ice_hw_to_dev(hw),
532+
"The driver for the device stopped because the NVM image is newer than expected. You must install the most recent version of the network driver.\n");
536533
return false;
534+
} else if (hw->api_maj_ver == EXP_FW_API_VER_MAJOR) {
535+
if (hw->api_min_ver > (EXP_FW_API_VER_MINOR + 2))
536+
dev_info(ice_hw_to_dev(hw),
537+
"The driver for the device detected a newer version of the NVM image than expected. Please install the most recent version of the network driver.\n");
538+
else if ((hw->api_min_ver + 2) < EXP_FW_API_VER_MINOR)
539+
dev_info(ice_hw_to_dev(hw),
540+
"The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n");
541+
} else {
542+
/* Major API version is older than expected, log a warning */
543+
dev_info(ice_hw_to_dev(hw),
544+
"The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n");
545+
}
537546
return true;
538547
}
539548

@@ -588,20 +597,19 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
588597
if (status)
589598
goto init_ctrlq_free_rq;
590599

591-
if (!ice_aq_ver_check(hw->api_branch, hw->api_maj_ver,
592-
hw->api_min_ver)) {
600+
if (!ice_aq_ver_check(hw)) {
593601
status = ICE_ERR_FW_API_VER;
594602
goto init_ctrlq_free_rq;
595603
}
596604

597605
return 0;
598606

599607
init_ctrlq_free_rq:
600-
if (cq->rq.head) {
608+
if (cq->rq.count) {
601609
ice_shutdown_rq(hw, cq);
602610
mutex_destroy(&cq->rq_lock);
603611
}
604-
if (cq->sq.head) {
612+
if (cq->sq.count) {
605613
ice_shutdown_sq(hw, cq);
606614
mutex_destroy(&cq->sq_lock);
607615
}
@@ -710,11 +718,11 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
710718
return;
711719
}
712720

713-
if (cq->sq.head) {
721+
if (cq->sq.count) {
714722
ice_shutdown_sq(hw, cq);
715723
mutex_destroy(&cq->sq_lock);
716724
}
717-
if (cq->rq.head) {
725+
if (cq->rq.count) {
718726
ice_shutdown_rq(hw, cq);
719727
mutex_destroy(&cq->rq_lock);
720728
}
@@ -850,7 +858,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
850858

851859
details = ICE_CTL_Q_DETAILS(cq->sq, cq->sq.next_to_use);
852860
if (cd)
853-
memcpy(details, cd, sizeof(*details));
861+
*details = *cd;
854862
else
855863
memset(details, 0, sizeof(*details));
856864

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
#define _ICE_DEVIDS_H_
66

77
/* Device IDs */
8-
/* Intel(R) Ethernet Controller C810 for backplane */
8+
/* Intel(R) Ethernet Controller E810-C for backplane */
99
#define ICE_DEV_ID_C810_BACKPLANE 0x1591
10-
/* Intel(R) Ethernet Controller C810 for QSFP */
10+
/* Intel(R) Ethernet Controller E810-C for QSFP */
1111
#define ICE_DEV_ID_C810_QSFP 0x1592
12-
/* Intel(R) Ethernet Controller C810 for SFP */
12+
/* Intel(R) Ethernet Controller E810-C for SFP */
1313
#define ICE_DEV_ID_C810_SFP 0x1593
14-
/* Intel(R) Ethernet Controller C810/X557-AT 10GBASE-T */
15-
#define ICE_DEV_ID_C810_10G_BASE_T 0x1594
16-
/* Intel(R) Ethernet Controller C810 1GbE */
17-
#define ICE_DEV_ID_C810_SGMII 0x1595
1814

1915
#endif /* _ICE_DEVIDS_H_ */

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,11 @@ ice_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
11981198
ring->tx_max_pending = ICE_MAX_NUM_DESC;
11991199
ring->rx_pending = vsi->rx_rings[0]->count;
12001200
ring->tx_pending = vsi->tx_rings[0]->count;
1201-
ring->rx_mini_pending = ICE_MIN_NUM_DESC;
1201+
1202+
/* Rx mini and jumbo rings are not supported */
12021203
ring->rx_mini_max_pending = 0;
12031204
ring->rx_jumbo_max_pending = 0;
1205+
ring->rx_mini_pending = 0;
12041206
ring->rx_jumbo_pending = 0;
12051207
}
12061208

@@ -1218,14 +1220,23 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
12181220
ring->tx_pending < ICE_MIN_NUM_DESC ||
12191221
ring->rx_pending > ICE_MAX_NUM_DESC ||
12201222
ring->rx_pending < ICE_MIN_NUM_DESC) {
1221-
netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
1223+
netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
12221224
ring->tx_pending, ring->rx_pending,
1223-
ICE_MIN_NUM_DESC, ICE_MAX_NUM_DESC);
1225+
ICE_MIN_NUM_DESC, ICE_MAX_NUM_DESC,
1226+
ICE_REQ_DESC_MULTIPLE);
12241227
return -EINVAL;
12251228
}
12261229

12271230
new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE);
1231+
if (new_tx_cnt != ring->tx_pending)
1232+
netdev_info(netdev,
1233+
"Requested Tx descriptor count rounded up to %d\n",
1234+
new_tx_cnt);
12281235
new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE);
1236+
if (new_rx_cnt != ring->rx_pending)
1237+
netdev_info(netdev,
1238+
"Requested Rx descriptor count rounded up to %d\n",
1239+
new_rx_cnt);
12291240

12301241
/* if nothing to do return success */
12311242
if (new_tx_cnt == vsi->tx_rings[0]->count &&

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,8 +3777,6 @@ static const struct pci_device_id ice_pci_tbl[] = {
37773777
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_BACKPLANE), 0 },
37783778
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_QSFP), 0 },
37793779
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SFP), 0 },
3780-
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_10G_BASE_T), 0 },
3781-
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SGMII), 0 },
37823780
/* required last entry */
37833781
{ 0, }
37843782
};

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

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,62 @@ ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid)
8484
return NULL;
8585
}
8686

87+
/**
88+
* ice_aq_query_sched_elems - query scheduler elements
89+
* @hw: pointer to the hw struct
90+
* @elems_req: number of elements to query
91+
* @buf: pointer to buffer
92+
* @buf_size: buffer size in bytes
93+
* @elems_ret: returns total number of elements returned
94+
* @cd: pointer to command details structure or NULL
95+
*
96+
* Query scheduling elements (0x0404)
97+
*/
98+
static enum ice_status
99+
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
100+
struct ice_aqc_get_elem *buf, u16 buf_size,
101+
u16 *elems_ret, struct ice_sq_cd *cd)
102+
{
103+
struct ice_aqc_get_cfg_elem *cmd;
104+
struct ice_aq_desc desc;
105+
enum ice_status status;
106+
107+
cmd = &desc.params.get_update_elem;
108+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sched_elems);
109+
cmd->num_elem_req = cpu_to_le16(elems_req);
110+
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
111+
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
112+
if (!status && elems_ret)
113+
*elems_ret = le16_to_cpu(cmd->num_elem_resp);
114+
115+
return status;
116+
}
117+
118+
/**
119+
* ice_sched_query_elem - query element information from hw
120+
* @hw: pointer to the hw struct
121+
* @node_teid: node teid to be queried
122+
* @buf: buffer to element information
123+
*
124+
* This function queries HW element information
125+
*/
126+
static enum ice_status
127+
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
128+
struct ice_aqc_get_elem *buf)
129+
{
130+
u16 buf_size, num_elem_ret = 0;
131+
enum ice_status status;
132+
133+
buf_size = sizeof(*buf);
134+
memset(buf, 0, buf_size);
135+
buf->generic[0].node_teid = cpu_to_le32(node_teid);
136+
status = ice_aq_query_sched_elems(hw, 1, buf, buf_size, &num_elem_ret,
137+
NULL);
138+
if (status || num_elem_ret != 1)
139+
ice_debug(hw, ICE_DBG_SCHED, "query element failed\n");
140+
return status;
141+
}
142+
87143
/**
88144
* ice_sched_add_node - Insert the Tx scheduler node in SW DB
89145
* @pi: port information structure
@@ -97,7 +153,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
97153
struct ice_aqc_txsched_elem_data *info)
98154
{
99155
struct ice_sched_node *parent;
156+
struct ice_aqc_get_elem elem;
100157
struct ice_sched_node *node;
158+
enum ice_status status;
101159
struct ice_hw *hw;
102160

103161
if (!pi)
@@ -115,6 +173,13 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
115173
return ICE_ERR_PARAM;
116174
}
117175

176+
/* query the current node information from FW before additing it
177+
* to the SW DB
178+
*/
179+
status = ice_sched_query_elem(hw, le32_to_cpu(info->node_teid), &elem);
180+
if (status)
181+
return status;
182+
118183
node = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*node), GFP_KERNEL);
119184
if (!node)
120185
return ICE_ERR_NO_MEMORY;
@@ -133,7 +198,7 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
133198
node->parent = parent;
134199
node->tx_sched_layer = layer;
135200
parent->children[parent->num_children++] = node;
136-
memcpy(&node->info, info, sizeof(*info));
201+
memcpy(&node->info, &elem.generic[0], sizeof(node->info));
137202
return 0;
138203
}
139204

0 commit comments

Comments
 (0)