aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_common.c
diff options
context:
space:
mode:
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>2018-09-19 20:42:55 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-10-03 10:42:29 -0400
commitddf30f7ff840d4467ef45ec0b443575f9e95bec6 (patch)
treec9059b346847f2818907c2857ea2db3860e51419 /drivers/net/ethernet/intel/ice/ice_common.c
parent75d2b253026b8b1cb625f6ccdb9d54cdecae7935 (diff)
ice: Add handler to configure SR-IOV
This patch implements parts of ice_sriov_configure and VF reset flow. To create virtual functions (VFs), the user sets a value in num_vfs through sysfs. This results in the kernel calling the handler for .sriov_configure which is ice_sriov_configure. VF setup first starts with a VF reset, followed by allocation of the VF VSI using ice_vf_vsi_setup. Once the VF setup is complete a state bit ICE_VF_STATE_INIT is set in the vf->states bitmap to indicate that the VF is ready to go. Also for VF reset to go into effect, it's necessary to issue a disable queue command (ice_aqc_opc_dis_txqs). So this patch updates multiple functions in the disable queue flow to take additional parameters that distinguish if queues are being disabled due to VF reset. Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_common.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_common.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 0fe054e4bfb8..c52f450f2c0d 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -2287,6 +2287,8 @@ ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
2287 * @num_qgrps: number of groups in the list 2287 * @num_qgrps: number of groups in the list
2288 * @qg_list: the list of groups to disable 2288 * @qg_list: the list of groups to disable
2289 * @buf_size: the total size of the qg_list buffer in bytes 2289 * @buf_size: the total size of the qg_list buffer in bytes
2290 * @rst_src: if called due to reset, specifies the RST source
2291 * @vmvf_num: the relative VM or VF number that is undergoing the reset
2290 * @cd: pointer to command details structure or NULL 2292 * @cd: pointer to command details structure or NULL
2291 * 2293 *
2292 * Disable LAN Tx queue (0x0C31) 2294 * Disable LAN Tx queue (0x0C31)
@@ -2294,6 +2296,7 @@ ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
2294static enum ice_status 2296static enum ice_status
2295ice_aq_dis_lan_txq(struct ice_hw *hw, u8 num_qgrps, 2297ice_aq_dis_lan_txq(struct ice_hw *hw, u8 num_qgrps,
2296 struct ice_aqc_dis_txq_item *qg_list, u16 buf_size, 2298 struct ice_aqc_dis_txq_item *qg_list, u16 buf_size,
2299 enum ice_disq_rst_src rst_src, u16 vmvf_num,
2297 struct ice_sq_cd *cd) 2300 struct ice_sq_cd *cd)
2298{ 2301{
2299 struct ice_aqc_dis_txqs *cmd; 2302 struct ice_aqc_dis_txqs *cmd;
@@ -2303,14 +2306,45 @@ ice_aq_dis_lan_txq(struct ice_hw *hw, u8 num_qgrps,
2303 cmd = &desc.params.dis_txqs; 2306 cmd = &desc.params.dis_txqs;
2304 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dis_txqs); 2307 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_dis_txqs);
2305 2308
2306 if (!qg_list) 2309 /* qg_list can be NULL only in VM/VF reset flow */
2310 if (!qg_list && !rst_src)
2307 return ICE_ERR_PARAM; 2311 return ICE_ERR_PARAM;
2308 2312
2309 if (num_qgrps > ICE_LAN_TXQ_MAX_QGRPS) 2313 if (num_qgrps > ICE_LAN_TXQ_MAX_QGRPS)
2310 return ICE_ERR_PARAM; 2314 return ICE_ERR_PARAM;
2311 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD); 2315
2312 cmd->num_entries = num_qgrps; 2316 cmd->num_entries = num_qgrps;
2313 2317
2318 cmd->vmvf_and_timeout = cpu_to_le16((5 << ICE_AQC_Q_DIS_TIMEOUT_S) &
2319 ICE_AQC_Q_DIS_TIMEOUT_M);
2320
2321 switch (rst_src) {
2322 case ICE_VM_RESET:
2323 cmd->cmd_type = ICE_AQC_Q_DIS_CMD_VM_RESET;
2324 cmd->vmvf_and_timeout |=
2325 cpu_to_le16(vmvf_num & ICE_AQC_Q_DIS_VMVF_NUM_M);
2326 break;
2327 case ICE_VF_RESET:
2328 cmd->cmd_type = ICE_AQC_Q_DIS_CMD_VF_RESET;
2329 /* In this case, FW expects vmvf_num to be absolute VF id */
2330 cmd->vmvf_and_timeout |=
2331 cpu_to_le16((vmvf_num + hw->func_caps.vf_base_id) &
2332 ICE_AQC_Q_DIS_VMVF_NUM_M);
2333 break;
2334 case ICE_NO_RESET:
2335 default:
2336 break;
2337 }
2338
2339 /* If no queue group info, we are in a reset flow. Issue the AQ */
2340 if (!qg_list)
2341 goto do_aq;
2342
2343 /* set RD bit to indicate that command buffer is provided by the driver
2344 * and it needs to be read by the firmware
2345 */
2346 desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
2347
2314 for (i = 0; i < num_qgrps; ++i) { 2348 for (i = 0; i < num_qgrps; ++i) {
2315 /* Calculate the size taken up by the queue IDs in this group */ 2349 /* Calculate the size taken up by the queue IDs in this group */
2316 sz += qg_list[i].num_qs * sizeof(qg_list[i].q_id); 2350 sz += qg_list[i].num_qs * sizeof(qg_list[i].q_id);
@@ -2326,6 +2360,7 @@ ice_aq_dis_lan_txq(struct ice_hw *hw, u8 num_qgrps,
2326 if (buf_size != sz) 2360 if (buf_size != sz)
2327 return ICE_ERR_PARAM; 2361 return ICE_ERR_PARAM;
2328 2362
2363do_aq:
2329 return ice_aq_send_cmd(hw, &desc, qg_list, buf_size, cd); 2364 return ice_aq_send_cmd(hw, &desc, qg_list, buf_size, cd);
2330} 2365}
2331 2366
@@ -2632,13 +2667,16 @@ ena_txq_exit:
2632 * @num_queues: number of queues 2667 * @num_queues: number of queues
2633 * @q_ids: pointer to the q_id array 2668 * @q_ids: pointer to the q_id array
2634 * @q_teids: pointer to queue node teids 2669 * @q_teids: pointer to queue node teids
2670 * @rst_src: if called due to reset, specifies the RST source
2671 * @vmvf_num: the relative VM or VF number that is undergoing the reset
2635 * @cd: pointer to command details structure or NULL 2672 * @cd: pointer to command details structure or NULL
2636 * 2673 *
2637 * This function removes queues and their corresponding nodes in SW DB 2674 * This function removes queues and their corresponding nodes in SW DB
2638 */ 2675 */
2639enum ice_status 2676enum ice_status
2640ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids, 2677ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
2641 u32 *q_teids, struct ice_sq_cd *cd) 2678 u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
2679 struct ice_sq_cd *cd)
2642{ 2680{
2643 enum ice_status status = ICE_ERR_DOES_NOT_EXIST; 2681 enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
2644 struct ice_aqc_dis_txq_item qg_list; 2682 struct ice_aqc_dis_txq_item qg_list;
@@ -2647,6 +2685,15 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
2647 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) 2685 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
2648 return ICE_ERR_CFG; 2686 return ICE_ERR_CFG;
2649 2687
2688 /* if queue is disabled already yet the disable queue command has to be
2689 * sent to complete the VF reset, then call ice_aq_dis_lan_txq without
2690 * any queue information
2691 */
2692
2693 if (!num_queues && rst_src)
2694 return ice_aq_dis_lan_txq(pi->hw, 0, NULL, 0, rst_src, vmvf_num,
2695 NULL);
2696
2650 mutex_lock(&pi->sched_lock); 2697 mutex_lock(&pi->sched_lock);
2651 2698
2652 for (i = 0; i < num_queues; i++) { 2699 for (i = 0; i < num_queues; i++) {
@@ -2659,7 +2706,8 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
2659 qg_list.num_qs = 1; 2706 qg_list.num_qs = 1;
2660 qg_list.q_id[0] = cpu_to_le16(q_ids[i]); 2707 qg_list.q_id[0] = cpu_to_le16(q_ids[i]);
2661 status = ice_aq_dis_lan_txq(pi->hw, 1, &qg_list, 2708 status = ice_aq_dis_lan_txq(pi->hw, 1, &qg_list,
2662 sizeof(qg_list), cd); 2709 sizeof(qg_list), rst_src, vmvf_num,
2710 cd);
2663 2711
2664 if (status) 2712 if (status)
2665 break; 2713 break;