aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-01-28 21:26:34 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-28 21:26:34 -0500
commit5abe9ead9a8f3217f1479961e778bec60d542c62 (patch)
treebb5fffe51418c6ebe71672b297699a66cbbb6a7e
parent457740a903db30b14d53060f4e10d8cdecf464ac (diff)
parent1563f2d2e01242f05dd523ffd56fe104bc1afd58 (diff)
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 2018-01-26 This series contains updates to i40e and i40evf. Michal updates the driver to pass critical errors from the firmware to the caller. Patryk fixes an issue of creating multiple identical filters with the same location, by simply moving the functions so that we remove the existing filter and then add the new filter. Paweł adds back in the ability to turn off offloads when VLAN is set for the VF driver. Fixed an issue where the number of TC queue pairs was exceeding MSI-X vectors count, causing messages about invalid TC mapping and wrong selected Tx queue. Alex cleans up the i40e/i40evf_set_itr_per_queue() by dropping all the unneeded pointer chases. Puts to use the reg_idx value, which was going unused, so that we can avoid having to compute the vector every time throughout the driver. Upasana enable the driver to display LLDP information on the vSphere Web Client by exposing DCB parameters. Alice converts our flags from 32 to 64 bit size, since we have added more flags. Dave implements a private ethtool flag to disable the processing of LLDP packets by the firmware, so that the firmware will not consume LLDPDU and cause them to be sent up the stack. Alan adds a mechanism for detecting/storing the flag for processing of LLDP packets by the firmware, so that its current state is persistent across reboots/reloads of the driver. Avinash fixes kdump with i40e due to resource constraints. We were enabling VMDq and iWARP when we just have a single CPU, which was starving kdump for the lack of IRQs. Jake adds support to program the fragmented IPv4 input set PCTYPE. Fixed the reported masks to properly report that the entire field is masked, since we had accidentally swapped the mask values for the IPv4 addresses with the L4 port numbers. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h67
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq.c15
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h12
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_common.c29
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c186
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c29
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_prototype.h4
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_status.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c12
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq.c15
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h12
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_common.c2
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_status.h1
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.c12
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf.h4
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c28
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c19
17 files changed, 342 insertions, 106 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index e019baa905c5..46e9f4e0a02c 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -508,39 +508,40 @@ struct i40e_pf {
508#define I40E_HW_PORT_ID_VALID BIT(17) 508#define I40E_HW_PORT_ID_VALID BIT(17)
509#define I40E_HW_RESTART_AUTONEG BIT(18) 509#define I40E_HW_RESTART_AUTONEG BIT(18)
510 510
511 u32 flags; 511 u64 flags;
512#define I40E_FLAG_RX_CSUM_ENABLED BIT(0) 512#define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(0)
513#define I40E_FLAG_MSI_ENABLED BIT(1) 513#define I40E_FLAG_MSI_ENABLED BIT_ULL(1)
514#define I40E_FLAG_MSIX_ENABLED BIT(2) 514#define I40E_FLAG_MSIX_ENABLED BIT_ULL(2)
515#define I40E_FLAG_RSS_ENABLED BIT(3) 515#define I40E_FLAG_RSS_ENABLED BIT_ULL(3)
516#define I40E_FLAG_VMDQ_ENABLED BIT(4) 516#define I40E_FLAG_VMDQ_ENABLED BIT_ULL(4)
517#define I40E_FLAG_FILTER_SYNC BIT(5) 517#define I40E_FLAG_FILTER_SYNC BIT_ULL(5)
518#define I40E_FLAG_SRIOV_ENABLED BIT(6) 518#define I40E_FLAG_SRIOV_ENABLED BIT_ULL(6)
519#define I40E_FLAG_DCB_CAPABLE BIT(7) 519#define I40E_FLAG_DCB_CAPABLE BIT_ULL(7)
520#define I40E_FLAG_DCB_ENABLED BIT(8) 520#define I40E_FLAG_DCB_ENABLED BIT_ULL(8)
521#define I40E_FLAG_FD_SB_ENABLED BIT(9) 521#define I40E_FLAG_FD_SB_ENABLED BIT_ULL(9)
522#define I40E_FLAG_FD_ATR_ENABLED BIT(10) 522#define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(10)
523#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT(11) 523#define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(11)
524#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT(12) 524#define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(12)
525#define I40E_FLAG_MFP_ENABLED BIT(13) 525#define I40E_FLAG_MFP_ENABLED BIT_ULL(13)
526#define I40E_FLAG_UDP_FILTER_SYNC BIT(14) 526#define I40E_FLAG_UDP_FILTER_SYNC BIT_ULL(14)
527#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT(15) 527#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(15)
528#define I40E_FLAG_VEB_MODE_ENABLED BIT(16) 528#define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(16)
529#define I40E_FLAG_VEB_STATS_ENABLED BIT(17) 529#define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(17)
530#define I40E_FLAG_LINK_POLLING_ENABLED BIT(18) 530#define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(18)
531#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT(19) 531#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(19)
532#define I40E_FLAG_TEMP_LINK_POLLING BIT(20) 532#define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(20)
533#define I40E_FLAG_LEGACY_RX BIT(21) 533#define I40E_FLAG_LEGACY_RX BIT_ULL(21)
534#define I40E_FLAG_PTP BIT(22) 534#define I40E_FLAG_PTP BIT_ULL(22)
535#define I40E_FLAG_IWARP_ENABLED BIT(23) 535#define I40E_FLAG_IWARP_ENABLED BIT_ULL(23)
536#define I40E_FLAG_SERVICE_CLIENT_REQUESTED BIT(24) 536#define I40E_FLAG_SERVICE_CLIENT_REQUESTED BIT_ULL(24)
537#define I40E_FLAG_CLIENT_L2_CHANGE BIT(25) 537#define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(25)
538#define I40E_FLAG_CLIENT_RESET BIT(26) 538#define I40E_FLAG_CLIENT_RESET BIT_ULL(26)
539#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT(27) 539#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT_ULL(27)
540#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT(28) 540#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT_ULL(28)
541#define I40E_FLAG_TC_MQPRIO BIT(29) 541#define I40E_FLAG_TC_MQPRIO BIT_ULL(29)
542#define I40E_FLAG_FD_SB_INACTIVE BIT(30) 542#define I40E_FLAG_FD_SB_INACTIVE BIT_ULL(30)
543#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT(31) 543#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT_ULL(31)
544#define I40E_FLAG_DISABLE_FW_LLDP BIT_ULL(32)
544 545
545 struct i40e_client_instance *cinst; 546 struct i40e_client_instance *cinst;
546 bool stat_offsets_loaded; 547 bool stat_offsets_loaded;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index d9670cd8743f..e78971605e0b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -907,10 +907,15 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
907 /* update the error if time out occurred */ 907 /* update the error if time out occurred */
908 if ((!cmd_completed) && 908 if ((!cmd_completed) &&
909 (!details->async && !details->postpone)) { 909 (!details->async && !details->postpone)) {
910 i40e_debug(hw, 910 if (rd32(hw, hw->aq.asq.len) & I40E_GL_ATQLEN_ATQCRIT_MASK) {
911 I40E_DEBUG_AQ_MESSAGE, 911 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
912 "AQTX: Writeback timeout.\n"); 912 "AQTX: AQ Critical error.\n");
913 status = I40E_ERR_ADMIN_QUEUE_TIMEOUT; 913 status = I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR;
914 } else {
915 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
916 "AQTX: Writeback timeout.\n");
917 status = I40E_ERR_ADMIN_QUEUE_TIMEOUT;
918 }
914 } 919 }
915 920
916asq_send_command_error: 921asq_send_command_error:
@@ -971,7 +976,7 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
971 } 976 }
972 977
973 /* set next_to_use to head */ 978 /* set next_to_use to head */
974 ntu = (rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK); 979 ntu = rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK;
975 if (ntu == ntc) { 980 if (ntu == ntc) {
976 /* nothing to do - shouldn't need to update ring's values */ 981 /* nothing to do - shouldn't need to update ring's values */
977 ret_code = I40E_ERR_ADMIN_QUEUE_NO_WORK; 982 ret_code = I40E_ERR_ADMIN_QUEUE_NO_WORK;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
index 0d471b0db0f4..a852775d3059 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
@@ -205,6 +205,7 @@ enum i40e_admin_queue_opc {
205 /* DCB commands */ 205 /* DCB commands */
206 i40e_aqc_opc_dcb_ignore_pfc = 0x0301, 206 i40e_aqc_opc_dcb_ignore_pfc = 0x0301,
207 i40e_aqc_opc_dcb_updated = 0x0302, 207 i40e_aqc_opc_dcb_updated = 0x0302,
208 i40e_aqc_opc_set_dcb_parameters = 0x0303,
208 209
209 /* TX scheduler */ 210 /* TX scheduler */
210 i40e_aqc_opc_configure_vsi_bw_limit = 0x0400, 211 i40e_aqc_opc_configure_vsi_bw_limit = 0x0400,
@@ -2496,6 +2497,17 @@ struct i40e_aqc_lldp_start {
2496 2497
2497I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start); 2498I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
2498 2499
2500/* Set DCB (direct 0x0303) */
2501struct i40e_aqc_set_dcb_parameters {
2502 u8 command;
2503#define I40E_AQ_DCB_SET_AGENT 0x1
2504#define I40E_DCB_VALID 0x1
2505 u8 valid_flags;
2506 u8 reserved[14];
2507};
2508
2509I40E_CHECK_CMD_LENGTH(i40e_aqc_set_dcb_parameters);
2510
2499/* Get CEE DCBX Oper Config (0x0A07) 2511/* Get CEE DCBX Oper Config (0x0A07)
2500 * uses the generic descriptor struct 2512 * uses the generic descriptor struct
2501 * returns below as indirect response 2513 * returns below as indirect response
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index ee6052ecd215..ef5a868aae46 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -278,6 +278,8 @@ const char *i40e_stat_str(struct i40e_hw *hw, i40e_status stat_err)
278 return "I40E_NOT_SUPPORTED"; 278 return "I40E_NOT_SUPPORTED";
279 case I40E_ERR_FIRMWARE_API_VERSION: 279 case I40E_ERR_FIRMWARE_API_VERSION:
280 return "I40E_ERR_FIRMWARE_API_VERSION"; 280 return "I40E_ERR_FIRMWARE_API_VERSION";
281 case I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
282 return "I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
281 } 283 }
282 284
283 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err); 285 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
@@ -3639,7 +3641,34 @@ i40e_status i40e_aq_start_lldp(struct i40e_hw *hw,
3639 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start); 3641 i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_lldp_start);
3640 3642
3641 cmd->command = I40E_AQ_LLDP_AGENT_START; 3643 cmd->command = I40E_AQ_LLDP_AGENT_START;
3644 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3642 3645
3646 return status;
3647}
3648
3649/**
3650 * i40e_aq_set_dcb_parameters
3651 * @hw: pointer to the hw struct
3652 * @cmd_details: pointer to command details structure or NULL
3653 * @dcb_enable: True if DCB configuration needs to be applied
3654 *
3655 **/
3656enum i40e_status_code
3657i40e_aq_set_dcb_parameters(struct i40e_hw *hw, bool dcb_enable,
3658 struct i40e_asq_cmd_details *cmd_details)
3659{
3660 struct i40e_aq_desc desc;
3661 struct i40e_aqc_set_dcb_parameters *cmd =
3662 (struct i40e_aqc_set_dcb_parameters *)&desc.params.raw;
3663 i40e_status status;
3664
3665 i40e_fill_default_direct_cmd_desc(&desc,
3666 i40e_aqc_opc_set_dcb_parameters);
3667
3668 if (dcb_enable) {
3669 cmd->valid_flags = I40E_DCB_VALID;
3670 cmd->command = I40E_AQ_DCB_SET_AGENT;
3671 }
3643 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); 3672 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
3644 3673
3645 return status; 3674 return status;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 34173f821fd9..2f5bee713fef 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -233,6 +233,7 @@ static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = {
233 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0), 233 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
234 I40E_PRIV_FLAG("disable-source-pruning", 234 I40E_PRIV_FLAG("disable-source-pruning",
235 I40E_FLAG_SOURCE_PRUNING_DISABLED, 0), 235 I40E_FLAG_SOURCE_PRUNING_DISABLED, 0),
236 I40E_PRIV_FLAG("disable-fw-lldp", I40E_FLAG_DISABLE_FW_LLDP, 0),
236}; 237};
237 238
238#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gstrings_priv_flags) 239#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gstrings_priv_flags)
@@ -2305,6 +2306,8 @@ static void i40e_set_itr_per_queue(struct i40e_vsi *vsi,
2305 struct ethtool_coalesce *ec, 2306 struct ethtool_coalesce *ec,
2306 int queue) 2307 int queue)
2307{ 2308{
2309 struct i40e_ring *rx_ring = vsi->rx_rings[queue];
2310 struct i40e_ring *tx_ring = vsi->tx_rings[queue];
2308 struct i40e_pf *pf = vsi->back; 2311 struct i40e_pf *pf = vsi->back;
2309 struct i40e_hw *hw = &pf->hw; 2312 struct i40e_hw *hw = &pf->hw;
2310 struct i40e_q_vector *q_vector; 2313 struct i40e_q_vector *q_vector;
@@ -2312,26 +2315,26 @@ static void i40e_set_itr_per_queue(struct i40e_vsi *vsi,
2312 2315
2313 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit); 2316 intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit);
2314 2317
2315 vsi->rx_rings[queue]->rx_itr_setting = ec->rx_coalesce_usecs; 2318 rx_ring->rx_itr_setting = ec->rx_coalesce_usecs;
2316 vsi->tx_rings[queue]->tx_itr_setting = ec->tx_coalesce_usecs; 2319 tx_ring->tx_itr_setting = ec->tx_coalesce_usecs;
2317 2320
2318 if (ec->use_adaptive_rx_coalesce) 2321 if (ec->use_adaptive_rx_coalesce)
2319 vsi->rx_rings[queue]->rx_itr_setting |= I40E_ITR_DYNAMIC; 2322 rx_ring->rx_itr_setting |= I40E_ITR_DYNAMIC;
2320 else 2323 else
2321 vsi->rx_rings[queue]->rx_itr_setting &= ~I40E_ITR_DYNAMIC; 2324 rx_ring->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
2322 2325
2323 if (ec->use_adaptive_tx_coalesce) 2326 if (ec->use_adaptive_tx_coalesce)
2324 vsi->tx_rings[queue]->tx_itr_setting |= I40E_ITR_DYNAMIC; 2327 tx_ring->tx_itr_setting |= I40E_ITR_DYNAMIC;
2325 else 2328 else
2326 vsi->tx_rings[queue]->tx_itr_setting &= ~I40E_ITR_DYNAMIC; 2329 tx_ring->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
2327 2330
2328 q_vector = vsi->rx_rings[queue]->q_vector; 2331 q_vector = rx_ring->q_vector;
2329 q_vector->rx.itr = ITR_TO_REG(vsi->rx_rings[queue]->rx_itr_setting); 2332 q_vector->rx.itr = ITR_TO_REG(rx_ring->rx_itr_setting);
2330 vector = vsi->base_vector + q_vector->v_idx; 2333 vector = vsi->base_vector + q_vector->v_idx;
2331 wr32(hw, I40E_PFINT_ITRN(I40E_RX_ITR, vector - 1), q_vector->rx.itr); 2334 wr32(hw, I40E_PFINT_ITRN(I40E_RX_ITR, vector - 1), q_vector->rx.itr);
2332 2335
2333 q_vector = vsi->tx_rings[queue]->q_vector; 2336 q_vector = tx_ring->q_vector;
2334 q_vector->tx.itr = ITR_TO_REG(vsi->tx_rings[queue]->tx_itr_setting); 2337 q_vector->tx.itr = ITR_TO_REG(tx_ring->tx_itr_setting);
2335 vector = vsi->base_vector + q_vector->v_idx; 2338 vector = vsi->base_vector + q_vector->v_idx;
2336 wr32(hw, I40E_PFINT_ITRN(I40E_TX_ITR, vector - 1), q_vector->tx.itr); 2339 wr32(hw, I40E_PFINT_ITRN(I40E_TX_ITR, vector - 1), q_vector->tx.itr);
2337 2340
@@ -2746,16 +2749,16 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
2746 2749
2747no_input_set: 2750no_input_set:
2748 if (input_set & I40E_L3_SRC_MASK) 2751 if (input_set & I40E_L3_SRC_MASK)
2749 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFF); 2752 fsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF);
2750 2753
2751 if (input_set & I40E_L3_DST_MASK) 2754 if (input_set & I40E_L3_DST_MASK)
2752 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFF); 2755 fsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF);
2753 2756
2754 if (input_set & I40E_L4_SRC_MASK) 2757 if (input_set & I40E_L4_SRC_MASK)
2755 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFFFFFF); 2758 fsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF);
2756 2759
2757 if (input_set & I40E_L4_DST_MASK) 2760 if (input_set & I40E_L4_DST_MASK)
2758 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFFFFFF); 2761 fsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF);
2759 2762
2760 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) 2763 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)
2761 fsp->ring_cookie = RX_CLS_FLOW_DISC; 2764 fsp->ring_cookie = RX_CLS_FLOW_DISC;
@@ -3806,6 +3809,16 @@ static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,
3806 3809
3807 i40e_write_fd_input_set(pf, index, new_mask); 3810 i40e_write_fd_input_set(pf, index, new_mask);
3808 3811
3812 /* IP_USER_FLOW filters match both IPv4/Other and IPv4/Fragmented
3813 * frames. If we're programming the input set for IPv4/Other, we also
3814 * need to program the IPv4/Fragmented input set. Since we don't have
3815 * separate support, we'll always assume and enforce that the two flow
3816 * types must have matching input sets.
3817 */
3818 if (index == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER)
3819 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV4,
3820 new_mask);
3821
3809 /* Add the new offset and update table, if necessary */ 3822 /* Add the new offset and update table, if necessary */
3810 if (new_flex_offset) { 3823 if (new_flex_offset) {
3811 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset, 3824 err = i40e_add_flex_offset(&pf->l4_flex_pit_list, src_offset,
@@ -3828,6 +3841,87 @@ static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,
3828} 3841}
3829 3842
3830/** 3843/**
3844 * i40e_match_fdir_filter - Return true of two filters match
3845 * @a: pointer to filter struct
3846 * @b: pointer to filter struct
3847 *
3848 * Returns true if the two filters match exactly the same criteria. I.e. they
3849 * match the same flow type and have the same parameters. We don't need to
3850 * check any input-set since all filters of the same flow type must use the
3851 * same input set.
3852 **/
3853static bool i40e_match_fdir_filter(struct i40e_fdir_filter *a,
3854 struct i40e_fdir_filter *b)
3855{
3856 /* The filters do not much if any of these criteria differ. */
3857 if (a->dst_ip != b->dst_ip ||
3858 a->src_ip != b->src_ip ||
3859 a->dst_port != b->dst_port ||
3860 a->src_port != b->src_port ||
3861 a->flow_type != b->flow_type ||
3862 a->ip4_proto != b->ip4_proto)
3863 return false;
3864
3865 return true;
3866}
3867
3868/**
3869 * i40e_disallow_matching_filters - Check that new filters differ
3870 * @vsi: pointer to the targeted VSI
3871 * @input: new filter to check
3872 *
3873 * Due to hardware limitations, it is not possible for two filters that match
3874 * similar criteria to be programmed at the same time. This is true for a few
3875 * reasons:
3876 *
3877 * (a) all filters matching a particular flow type must use the same input
3878 * set, that is they must match the same criteria.
3879 * (b) different flow types will never match the same packet, as the flow type
3880 * is decided by hardware before checking which rules apply.
3881 * (c) hardware has no way to distinguish which order filters apply in.
3882 *
3883 * Due to this, we can't really support using the location data to order
3884 * filters in the hardware parsing. It is technically possible for the user to
3885 * request two filters matching the same criteria but which select different
3886 * queues. In this case, rather than keep both filters in the list, we reject
3887 * the 2nd filter when the user requests adding it.
3888 *
3889 * This avoids needing to track location for programming the filter to
3890 * hardware, and ensures that we avoid some strange scenarios involving
3891 * deleting filters which match the same criteria.
3892 **/
3893static int i40e_disallow_matching_filters(struct i40e_vsi *vsi,
3894 struct i40e_fdir_filter *input)
3895{
3896 struct i40e_pf *pf = vsi->back;
3897 struct i40e_fdir_filter *rule;
3898 struct hlist_node *node2;
3899
3900 /* Loop through every filter, and check that it doesn't match */
3901 hlist_for_each_entry_safe(rule, node2,
3902 &pf->fdir_filter_list, fdir_node) {
3903 /* Don't check the filters match if they share the same fd_id,
3904 * since the new filter is actually just updating the target
3905 * of the old filter.
3906 */
3907 if (rule->fd_id == input->fd_id)
3908 continue;
3909
3910 /* If any filters match, then print a warning message to the
3911 * kernel message buffer and bail out.
3912 */
3913 if (i40e_match_fdir_filter(rule, input)) {
3914 dev_warn(&pf->pdev->dev,
3915 "Existing user defined filter %d already matches this flow.\n",
3916 rule->fd_id);
3917 return -EINVAL;
3918 }
3919 }
3920
3921 return 0;
3922}
3923
3924/**
3831 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters 3925 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
3832 * @vsi: pointer to the targeted VSI 3926 * @vsi: pointer to the targeted VSI
3833 * @cmd: command to get or set RX flow classification rules 3927 * @cmd: command to get or set RX flow classification rules
@@ -3939,19 +4033,25 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
3939 input->flex_offset = userdef.flex_offset; 4033 input->flex_offset = userdef.flex_offset;
3940 } 4034 }
3941 4035
3942 ret = i40e_add_del_fdir(vsi, input, true); 4036 /* Avoid programming two filters with identical match criteria. */
4037 ret = i40e_disallow_matching_filters(vsi, input);
3943 if (ret) 4038 if (ret)
3944 goto free_input; 4039 goto free_filter_memory;
3945 4040
3946 /* Add the input filter to the fdir_input_list, possibly replacing 4041 /* Add the input filter to the fdir_input_list, possibly replacing
3947 * a previous filter. Do not free the input structure after adding it 4042 * a previous filter. Do not free the input structure after adding it
3948 * to the list as this would cause a use-after-free bug. 4043 * to the list as this would cause a use-after-free bug.
3949 */ 4044 */
3950 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); 4045 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
3951 4046 ret = i40e_add_del_fdir(vsi, input, true);
4047 if (ret)
4048 goto remove_sw_rule;
3952 return 0; 4049 return 0;
3953 4050
3954free_input: 4051remove_sw_rule:
4052 hlist_del(&input->fdir_node);
4053 pf->fdir_pf_active_filters--;
4054free_filter_memory:
3955 kfree(input); 4055 kfree(input);
3956 return ret; 4056 return ret;
3957} 4057}
@@ -4264,7 +4364,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
4264 struct i40e_netdev_priv *np = netdev_priv(dev); 4364 struct i40e_netdev_priv *np = netdev_priv(dev);
4265 struct i40e_vsi *vsi = np->vsi; 4365 struct i40e_vsi *vsi = np->vsi;
4266 struct i40e_pf *pf = vsi->back; 4366 struct i40e_pf *pf = vsi->back;
4267 u32 orig_flags, new_flags, changed_flags; 4367 u64 orig_flags, new_flags, changed_flags;
4268 u32 i, j; 4368 u32 i, j;
4269 4369
4270 orig_flags = READ_ONCE(pf->flags); 4370 orig_flags = READ_ONCE(pf->flags);
@@ -4315,13 +4415,32 @@ flags_complete:
4315 !(pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE)) 4415 !(pf->hw_features & I40E_HW_ATR_EVICT_CAPABLE))
4316 return -EOPNOTSUPP; 4416 return -EOPNOTSUPP;
4317 4417
4418 /* Disable FW LLDP not supported if NPAR active or if FW
4419 * API version < 1.7
4420 */
4421 if (new_flags & I40E_FLAG_DISABLE_FW_LLDP) {
4422 if (pf->hw.func_caps.npar_enable) {
4423 dev_warn(&pf->pdev->dev,
4424 "Unable to stop FW LLDP if NPAR active\n");
4425 return -EOPNOTSUPP;
4426 }
4427
4428 if (pf->hw.aq.api_maj_ver < 1 ||
4429 (pf->hw.aq.api_maj_ver == 1 &&
4430 pf->hw.aq.api_min_ver < 7)) {
4431 dev_warn(&pf->pdev->dev,
4432 "FW ver does not support stopping FW LLDP\n");
4433 return -EOPNOTSUPP;
4434 }
4435 }
4436
4318 /* Compare and exchange the new flags into place. If we failed, that 4437 /* Compare and exchange the new flags into place. If we failed, that
4319 * is if cmpxchg returns anything but the old value, this means that 4438 * is if cmpxchg returns anything but the old value, this means that
4320 * something else has modified the flags variable since we copied it 4439 * something else has modified the flags variable since we copied it
4321 * originally. We'll just punt with an error and log something in the 4440 * originally. We'll just punt with an error and log something in the
4322 * message buffer. 4441 * message buffer.
4323 */ 4442 */
4324 if (cmpxchg(&pf->flags, orig_flags, new_flags) != orig_flags) { 4443 if (cmpxchg64(&pf->flags, orig_flags, new_flags) != orig_flags) {
4325 dev_warn(&pf->pdev->dev, 4444 dev_warn(&pf->pdev->dev,
4326 "Unable to update pf->flags as it was modified by another thread...\n"); 4445 "Unable to update pf->flags as it was modified by another thread...\n");
4327 return -EAGAIN; 4446 return -EAGAIN;
@@ -4360,12 +4479,37 @@ flags_complete:
4360 } 4479 }
4361 } 4480 }
4362 4481
4482 if (changed_flags & I40E_FLAG_DISABLE_FW_LLDP) {
4483 if (pf->flags & I40E_FLAG_DISABLE_FW_LLDP) {
4484 struct i40e_dcbx_config *dcbcfg;
4485 int i;
4486
4487 i40e_aq_stop_lldp(&pf->hw, true, NULL);
4488 i40e_aq_set_dcb_parameters(&pf->hw, true, NULL);
4489 /* reset local_dcbx_config to default */
4490 dcbcfg = &pf->hw.local_dcbx_config;
4491 dcbcfg->etscfg.willing = 1;
4492 dcbcfg->etscfg.maxtcs = 0;
4493 dcbcfg->etscfg.tcbwtable[0] = 100;
4494 for (i = 1; i < I40E_MAX_TRAFFIC_CLASS; i++)
4495 dcbcfg->etscfg.tcbwtable[i] = 0;
4496 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
4497 dcbcfg->etscfg.prioritytable[i] = 0;
4498 dcbcfg->etscfg.tsatable[0] = I40E_IEEE_TSA_ETS;
4499 dcbcfg->pfc.willing = 1;
4500 dcbcfg->pfc.pfccap = I40E_MAX_TRAFFIC_CLASS;
4501 } else {
4502 i40e_aq_start_lldp(&pf->hw, NULL);
4503 }
4504 }
4505
4363 /* Issue reset to cause things to take effect, as additional bits 4506 /* Issue reset to cause things to take effect, as additional bits
4364 * are added we will need to create a mask of bits requiring reset 4507 * are added we will need to create a mask of bits requiring reset
4365 */ 4508 */
4366 if (changed_flags & (I40E_FLAG_VEB_STATS_ENABLED | 4509 if (changed_flags & (I40E_FLAG_VEB_STATS_ENABLED |
4367 I40E_FLAG_LEGACY_RX | 4510 I40E_FLAG_LEGACY_RX |
4368 I40E_FLAG_SOURCE_PRUNING_DISABLED)) 4511 I40E_FLAG_SOURCE_PRUNING_DISABLED |
4512 I40E_FLAG_DISABLE_FW_LLDP))
4369 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED), true); 4513 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED), true);
4370 4514
4371 return 0; 4515 return 0;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 2703a92f3778..f95ce9b5e4fb 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -1818,6 +1818,10 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi,
1818 num_tc_qps = qcount / numtc; 1818 num_tc_qps = qcount / numtc;
1819 num_tc_qps = min_t(int, num_tc_qps, i40e_pf_get_max_q_per_tc(pf)); 1819 num_tc_qps = min_t(int, num_tc_qps, i40e_pf_get_max_q_per_tc(pf));
1820 1820
1821 /* Do not allow use more TC queue pairs than MSI-X vectors exist */
1822 if (pf->flags & I40E_FLAG_MSIX_ENABLED)
1823 num_tc_qps = min_t(int, num_tc_qps, pf->num_lan_msix);
1824
1821 /* Setup queue offset/count for all TCs for given VSI */ 1825 /* Setup queue offset/count for all TCs for given VSI */
1822 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { 1826 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1823 /* See if the given TC is enabled for the given VSI */ 1827 /* See if the given TC is enabled for the given VSI */
@@ -4122,6 +4126,7 @@ static void i40e_vsi_map_rings_to_vectors(struct i40e_vsi *vsi)
4122 num_ringpairs = DIV_ROUND_UP(qp_remaining, q_vectors - v_start); 4126 num_ringpairs = DIV_ROUND_UP(qp_remaining, q_vectors - v_start);
4123 4127
4124 q_vector->num_ringpairs = num_ringpairs; 4128 q_vector->num_ringpairs = num_ringpairs;
4129 q_vector->reg_idx = q_vector->v_idx + vsi->base_vector - 1;
4125 4130
4126 q_vector->rx.count = 0; 4131 q_vector->rx.count = 0;
4127 q_vector->tx.count = 0; 4132 q_vector->tx.count = 0;
@@ -6320,8 +6325,11 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf)
6320 struct i40e_hw *hw = &pf->hw; 6325 struct i40e_hw *hw = &pf->hw;
6321 int err = 0; 6326 int err = 0;
6322 6327
6323 /* Do not enable DCB for SW1 and SW2 images even if the FW is capable */ 6328 /* Do not enable DCB for SW1 and SW2 images even if the FW is capable
6324 if (pf->hw_features & I40E_HW_NO_DCB_SUPPORT) 6329 * Also do not enable DCBx if FW LLDP agent is disabled
6330 */
6331 if ((pf->hw_features & I40E_HW_NO_DCB_SUPPORT) ||
6332 (pf->flags & I40E_FLAG_DISABLE_FW_LLDP))
6325 goto out; 6333 goto out;
6326 6334
6327 /* Get the initial DCB configuration */ 6335 /* Get the initial DCB configuration */
@@ -6348,6 +6356,9 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf)
6348 dev_dbg(&pf->pdev->dev, 6356 dev_dbg(&pf->pdev->dev,
6349 "DCBX offload is supported for this PF.\n"); 6357 "DCBX offload is supported for this PF.\n");
6350 } 6358 }
6359 } else if (pf->hw.aq.asq_last_status == I40E_AQ_RC_EPERM) {
6360 dev_info(&pf->pdev->dev, "FW LLDP disabled for this PF.\n");
6361 pf->flags |= I40E_FLAG_DISABLE_FW_LLDP;
6351 } else { 6362 } else {
6352 dev_info(&pf->pdev->dev, 6363 dev_info(&pf->pdev->dev,
6353 "Query for DCB configuration failed, err %s aq_err %s\n", 6364 "Query for DCB configuration failed, err %s aq_err %s\n",
@@ -7674,6 +7685,9 @@ static void i40e_fdir_filter_exit(struct i40e_pf *pf)
7674 /* Reprogram the default input set for Other/IPv4 */ 7685 /* Reprogram the default input set for Other/IPv4 */
7675 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_OTHER, 7686 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_NONF_IPV4_OTHER,
7676 I40E_L3_SRC_MASK | I40E_L3_DST_MASK); 7687 I40E_L3_SRC_MASK | I40E_L3_DST_MASK);
7688
7689 i40e_write_fd_input_set(pf, I40E_FILTER_PCTYPE_FRAG_IPV4,
7690 I40E_L3_SRC_MASK | I40E_L3_DST_MASK);
7677} 7691}
7678 7692
7679/** 7693/**
@@ -9221,6 +9235,9 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
9221 goto end_core_reset; 9235 goto end_core_reset;
9222 } 9236 }
9223 9237
9238 /* Enable FW to write a default DCB config on link-up */
9239 i40e_aq_set_dcb_parameters(hw, true, NULL);
9240
9224#ifdef CONFIG_I40E_DCB 9241#ifdef CONFIG_I40E_DCB
9225 ret = i40e_init_pf_dcb(pf); 9242 ret = i40e_init_pf_dcb(pf);
9226 if (ret) { 9243 if (ret) {
@@ -11060,13 +11077,13 @@ static int i40e_sw_init(struct i40e_pf *pf)
11060 pf->hw.aq.fw_maj_ver >= 6) 11077 pf->hw.aq.fw_maj_ver >= 6)
11061 pf->hw_features |= I40E_HW_PTP_L4_CAPABLE; 11078 pf->hw_features |= I40E_HW_PTP_L4_CAPABLE;
11062 11079
11063 if (pf->hw.func_caps.vmdq) { 11080 if (pf->hw.func_caps.vmdq && num_online_cpus() != 1) {
11064 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI; 11081 pf->num_vmdq_vsis = I40E_DEFAULT_NUM_VMDQ_VSI;
11065 pf->flags |= I40E_FLAG_VMDQ_ENABLED; 11082 pf->flags |= I40E_FLAG_VMDQ_ENABLED;
11066 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf); 11083 pf->num_vmdq_qps = i40e_default_queues_per_vmdq(pf);
11067 } 11084 }
11068 11085
11069 if (pf->hw.func_caps.iwarp) { 11086 if (pf->hw.func_caps.iwarp && num_online_cpus() != 1) {
11070 pf->flags |= I40E_FLAG_IWARP_ENABLED; 11087 pf->flags |= I40E_FLAG_IWARP_ENABLED;
11071 /* IWARP needs one extra vector for CQP just like MISC.*/ 11088 /* IWARP needs one extra vector for CQP just like MISC.*/
11072 pf->num_iwarp_msix = (int)num_online_cpus() + 1; 11089 pf->num_iwarp_msix = (int)num_online_cpus() + 1;
@@ -13543,6 +13560,10 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
13543 13560
13544 pci_set_drvdata(pdev, pf); 13561 pci_set_drvdata(pdev, pf);
13545 pci_save_state(pdev); 13562 pci_save_state(pdev);
13563
13564 /* Enable FW to write default DCB config on link-up */
13565 i40e_aq_set_dcb_parameters(hw, true, NULL);
13566
13546#ifdef CONFIG_I40E_DCB 13567#ifdef CONFIG_I40E_DCB
13547 err = i40e_init_pf_dcb(pf); 13568 err = i40e_init_pf_dcb(pf);
13548 if (err) { 13569 if (err) {
diff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
index 187dd53e0056..83798b7841b9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
@@ -225,6 +225,10 @@ i40e_status i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
225 struct i40e_asq_cmd_details *cmd_details); 225 struct i40e_asq_cmd_details *cmd_details);
226i40e_status i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent, 226i40e_status i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
227 struct i40e_asq_cmd_details *cmd_details); 227 struct i40e_asq_cmd_details *cmd_details);
228i40e_status i40e_aq_set_dcb_parameters(struct i40e_hw *hw,
229 bool dcb_enable,
230 struct i40e_asq_cmd_details
231 *cmd_details);
228i40e_status i40e_aq_start_lldp(struct i40e_hw *hw, 232i40e_status i40e_aq_start_lldp(struct i40e_hw *hw,
229 struct i40e_asq_cmd_details *cmd_details); 233 struct i40e_asq_cmd_details *cmd_details);
230i40e_status i40e_aq_get_cee_dcb_config(struct i40e_hw *hw, 234i40e_status i40e_aq_get_cee_dcb_config(struct i40e_hw *hw,
diff --git a/drivers/net/ethernet/intel/i40e/i40e_status.h b/drivers/net/ethernet/intel/i40e/i40e_status.h
index 5f9cac55aa55..afb72e711d43 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_status.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_status.h
@@ -95,6 +95,7 @@ enum i40e_status_code {
95 I40E_ERR_NOT_READY = -63, 95 I40E_ERR_NOT_READY = -63,
96 I40E_NOT_SUPPORTED = -64, 96 I40E_NOT_SUPPORTED = -64,
97 I40E_ERR_FIRMWARE_API_VERSION = -65, 97 I40E_ERR_FIRMWARE_API_VERSION = -65,
98 I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR = -66,
98}; 99};
99 100
100#endif /* _I40E_STATUS_H_ */ 101#endif /* _I40E_STATUS_H_ */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 8d2275830a40..e554aa6cf070 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -956,7 +956,7 @@ static void i40e_enable_wb_on_itr(struct i40e_vsi *vsi,
956 I40E_PFINT_DYN_CTLN_ITR_INDX_MASK; /* set noitr */ 956 I40E_PFINT_DYN_CTLN_ITR_INDX_MASK; /* set noitr */
957 957
958 wr32(&vsi->back->hw, 958 wr32(&vsi->back->hw,
959 I40E_PFINT_DYN_CTLN(q_vector->v_idx + vsi->base_vector - 1), 959 I40E_PFINT_DYN_CTLN(q_vector->reg_idx),
960 val); 960 val);
961 } else { 961 } else {
962 val = I40E_PFINT_DYN_CTL0_WB_ON_ITR_MASK | 962 val = I40E_PFINT_DYN_CTL0_WB_ON_ITR_MASK |
@@ -983,8 +983,7 @@ void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
983 /* allow 00 to be written to the index */ 983 /* allow 00 to be written to the index */
984 984
985 wr32(&vsi->back->hw, 985 wr32(&vsi->back->hw,
986 I40E_PFINT_DYN_CTLN(q_vector->v_idx + 986 I40E_PFINT_DYN_CTLN(q_vector->reg_idx), val);
987 vsi->base_vector - 1), val);
988 } else { 987 } else {
989 u32 val = I40E_PFINT_DYN_CTL0_INTENA_MASK | 988 u32 val = I40E_PFINT_DYN_CTL0_INTENA_MASK |
990 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK | /* set noitr */ 989 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK | /* set noitr */
@@ -2311,7 +2310,6 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,
2311 struct i40e_hw *hw = &vsi->back->hw; 2310 struct i40e_hw *hw = &vsi->back->hw;
2312 bool rx = false, tx = false; 2311 bool rx = false, tx = false;
2313 u32 rxval, txval; 2312 u32 rxval, txval;
2314 int vector;
2315 int idx = q_vector->v_idx; 2313 int idx = q_vector->v_idx;
2316 int rx_itr_setting, tx_itr_setting; 2314 int rx_itr_setting, tx_itr_setting;
2317 2315
@@ -2321,8 +2319,6 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,
2321 return; 2319 return;
2322 } 2320 }
2323 2321
2324 vector = (q_vector->v_idx + vsi->base_vector);
2325
2326 /* avoid dynamic calculation if in countdown mode OR if 2322 /* avoid dynamic calculation if in countdown mode OR if
2327 * all dynamic is disabled 2323 * all dynamic is disabled
2328 */ 2324 */
@@ -2371,12 +2367,12 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,
2371 */ 2367 */
2372 rxval |= BIT(31); 2368 rxval |= BIT(31);
2373 /* don't check _DOWN because interrupt isn't being enabled */ 2369 /* don't check _DOWN because interrupt isn't being enabled */
2374 wr32(hw, INTREG(vector - 1), rxval); 2370 wr32(hw, INTREG(q_vector->reg_idx), rxval);
2375 } 2371 }
2376 2372
2377enable_int: 2373enable_int:
2378 if (!test_bit(__I40E_VSI_DOWN, vsi->state)) 2374 if (!test_bit(__I40E_VSI_DOWN, vsi->state))
2379 wr32(hw, INTREG(vector - 1), txval); 2375 wr32(hw, INTREG(q_vector->reg_idx), txval);
2380 2376
2381 if (q_vector->itr_countdown) 2377 if (q_vector->itr_countdown)
2382 q_vector->itr_countdown--; 2378 q_vector->itr_countdown--;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
index 8b0d4b255dea..d1aab6b8bfb1 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
@@ -837,10 +837,15 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
837 /* update the error if time out occurred */ 837 /* update the error if time out occurred */
838 if ((!cmd_completed) && 838 if ((!cmd_completed) &&
839 (!details->async && !details->postpone)) { 839 (!details->async && !details->postpone)) {
840 i40e_debug(hw, 840 if (rd32(hw, hw->aq.asq.len) & I40E_VF_ATQLEN1_ATQCRIT_MASK) {
841 I40E_DEBUG_AQ_MESSAGE, 841 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
842 "AQTX: Writeback timeout.\n"); 842 "AQTX: AQ Critical error.\n");
843 status = I40E_ERR_ADMIN_QUEUE_TIMEOUT; 843 status = I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR;
844 } else {
845 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
846 "AQTX: Writeback timeout.\n");
847 status = I40E_ERR_ADMIN_QUEUE_TIMEOUT;
848 }
844 } 849 }
845 850
846asq_send_command_error: 851asq_send_command_error:
@@ -901,7 +906,7 @@ i40e_status i40evf_clean_arq_element(struct i40e_hw *hw,
901 } 906 }
902 907
903 /* set next_to_use to head */ 908 /* set next_to_use to head */
904 ntu = (rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK); 909 ntu = rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK;
905 if (ntu == ntc) { 910 if (ntu == ntc) {
906 /* nothing to do - shouldn't need to update ring's values */ 911 /* nothing to do - shouldn't need to update ring's values */
907 ret_code = I40E_ERR_ADMIN_QUEUE_NO_WORK; 912 ret_code = I40E_ERR_ADMIN_QUEUE_NO_WORK;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
index b0e6454995b6..815de8d9c3fb 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
@@ -205,6 +205,7 @@ enum i40e_admin_queue_opc {
205 /* DCB commands */ 205 /* DCB commands */
206 i40e_aqc_opc_dcb_ignore_pfc = 0x0301, 206 i40e_aqc_opc_dcb_ignore_pfc = 0x0301,
207 i40e_aqc_opc_dcb_updated = 0x0302, 207 i40e_aqc_opc_dcb_updated = 0x0302,
208 i40e_aqc_opc_set_dcb_parameters = 0x0303,
208 209
209 /* TX scheduler */ 210 /* TX scheduler */
210 i40e_aqc_opc_configure_vsi_bw_limit = 0x0400, 211 i40e_aqc_opc_configure_vsi_bw_limit = 0x0400,
@@ -2461,6 +2462,17 @@ struct i40e_aqc_lldp_start {
2461 2462
2462I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start); 2463I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
2463 2464
2465/* Set DCB (direct 0x0303) */
2466struct i40e_aqc_set_dcb_parameters {
2467 u8 command;
2468#define I40E_AQ_DCB_SET_AGENT 0x1
2469#define I40E_DCB_VALID 0x1
2470 u8 valid_flags;
2471 u8 reserved[14];
2472};
2473
2474I40E_CHECK_CMD_LENGTH(i40e_aqc_set_dcb_parameters);
2475
2464/* Apply MIB changes (0x0A07) 2476/* Apply MIB changes (0x0A07)
2465 * uses the generic struc as it contains no data 2477 * uses the generic struc as it contains no data
2466 */ 2478 */
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_common.c b/drivers/net/ethernet/intel/i40evf/i40e_common.c
index a94648429a5b..67bf5cebb76f 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_common.c
@@ -284,6 +284,8 @@ const char *i40evf_stat_str(struct i40e_hw *hw, i40e_status stat_err)
284 return "I40E_NOT_SUPPORTED"; 284 return "I40E_NOT_SUPPORTED";
285 case I40E_ERR_FIRMWARE_API_VERSION: 285 case I40E_ERR_FIRMWARE_API_VERSION:
286 return "I40E_ERR_FIRMWARE_API_VERSION"; 286 return "I40E_ERR_FIRMWARE_API_VERSION";
287 case I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
288 return "I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
287 } 289 }
288 290
289 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err); 291 snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_status.h b/drivers/net/ethernet/intel/i40evf/i40e_status.h
index 7fa7a41915c1..5b222246e08b 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_status.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_status.h
@@ -95,6 +95,7 @@ enum i40e_status_code {
95 I40E_ERR_NOT_READY = -63, 95 I40E_ERR_NOT_READY = -63,
96 I40E_NOT_SUPPORTED = -64, 96 I40E_NOT_SUPPORTED = -64,
97 I40E_ERR_FIRMWARE_API_VERSION = -65, 97 I40E_ERR_FIRMWARE_API_VERSION = -65,
98 I40E_ERR_ADMIN_QUEUE_CRITICAL_ERROR = -66,
98}; 99};
99 100
100#endif /* _I40E_STATUS_H_ */ 101#endif /* _I40E_STATUS_H_ */
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index c7831f7f7761..357d6051281f 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -369,8 +369,7 @@ static void i40e_enable_wb_on_itr(struct i40e_vsi *vsi,
369 I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK; /* set noitr */ 369 I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK; /* set noitr */
370 370
371 wr32(&vsi->back->hw, 371 wr32(&vsi->back->hw,
372 I40E_VFINT_DYN_CTLN1(q_vector->v_idx + 372 I40E_VFINT_DYN_CTLN1(q_vector->reg_idx), val);
373 vsi->base_vector - 1), val);
374 q_vector->arm_wb_state = true; 373 q_vector->arm_wb_state = true;
375} 374}
376 375
@@ -389,7 +388,7 @@ void i40evf_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
389 /* allow 00 to be written to the index */; 388 /* allow 00 to be written to the index */;
390 389
391 wr32(&vsi->back->hw, 390 wr32(&vsi->back->hw,
392 I40E_VFINT_DYN_CTLN1(q_vector->v_idx + vsi->base_vector - 1), 391 I40E_VFINT_DYN_CTLN1(q_vector->reg_idx),
393 val); 392 val);
394} 393}
395 394
@@ -1498,12 +1497,9 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,
1498 struct i40e_hw *hw = &vsi->back->hw; 1497 struct i40e_hw *hw = &vsi->back->hw;
1499 bool rx = false, tx = false; 1498 bool rx = false, tx = false;
1500 u32 rxval, txval; 1499 u32 rxval, txval;
1501 int vector;
1502 int idx = q_vector->v_idx; 1500 int idx = q_vector->v_idx;
1503 int rx_itr_setting, tx_itr_setting; 1501 int rx_itr_setting, tx_itr_setting;
1504 1502
1505 vector = (q_vector->v_idx + vsi->base_vector);
1506
1507 /* avoid dynamic calculation if in countdown mode OR if 1503 /* avoid dynamic calculation if in countdown mode OR if
1508 * all dynamic is disabled 1504 * all dynamic is disabled
1509 */ 1505 */
@@ -1552,12 +1548,12 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,
1552 */ 1548 */
1553 rxval |= BIT(31); 1549 rxval |= BIT(31);
1554 /* don't check _DOWN because interrupt isn't being enabled */ 1550 /* don't check _DOWN because interrupt isn't being enabled */
1555 wr32(hw, INTREG(vector - 1), rxval); 1551 wr32(hw, INTREG(q_vector->reg_idx), rxval);
1556 } 1552 }
1557 1553
1558enable_int: 1554enable_int:
1559 if (!test_bit(__I40E_VSI_DOWN, vsi->state)) 1555 if (!test_bit(__I40E_VSI_DOWN, vsi->state))
1560 wr32(hw, INTREG(vector - 1), txval); 1556 wr32(hw, INTREG(q_vector->reg_idx), txval);
1561 1557
1562 if (q_vector->itr_countdown) 1558 if (q_vector->itr_countdown)
1563 q_vector->itr_countdown--; 1559 q_vector->itr_countdown--;
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h b/drivers/net/ethernet/intel/i40evf/i40evf.h
index 33c0ffcc8b13..9690c1ea019e 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf.h
+++ b/drivers/net/ethernet/intel/i40evf/i40evf.h
@@ -114,14 +114,14 @@ struct i40e_q_vector {
114 struct i40evf_adapter *adapter; 114 struct i40evf_adapter *adapter;
115 struct i40e_vsi *vsi; 115 struct i40e_vsi *vsi;
116 struct napi_struct napi; 116 struct napi_struct napi;
117 unsigned long reg_idx;
118 struct i40e_ring_container rx; 117 struct i40e_ring_container rx;
119 struct i40e_ring_container tx; 118 struct i40e_ring_container tx;
120 u32 ring_mask; 119 u32 ring_mask;
121 u8 num_ringpairs; /* total number of ring pairs in vector */ 120 u8 num_ringpairs; /* total number of ring pairs in vector */
122#define ITR_COUNTDOWN_START 100 121#define ITR_COUNTDOWN_START 100
123 u8 itr_countdown; /* when 0 or 1 update ITR */ 122 u8 itr_countdown; /* when 0 or 1 update ITR */
124 int v_idx; /* vector index in list */ 123 u16 v_idx; /* index in the vsi->q_vector array. */
124 u16 reg_idx; /* register index of the interrupt */
125 char name[IFNAMSIZ + 15]; 125 char name[IFNAMSIZ + 15];
126 bool arm_wb_state; 126 bool arm_wb_state;
127 cpumask_t affinity_mask; 127 cpumask_t affinity_mask;
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
index da006fa3fec1..e2d8aa19d205 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
@@ -512,31 +512,31 @@ static void i40evf_set_itr_per_queue(struct i40evf_adapter *adapter,
512 struct ethtool_coalesce *ec, 512 struct ethtool_coalesce *ec,
513 int queue) 513 int queue)
514{ 514{
515 struct i40e_ring *rx_ring = &adapter->rx_rings[queue];
516 struct i40e_ring *tx_ring = &adapter->tx_rings[queue];
515 struct i40e_vsi *vsi = &adapter->vsi; 517 struct i40e_vsi *vsi = &adapter->vsi;
516 struct i40e_hw *hw = &adapter->hw; 518 struct i40e_hw *hw = &adapter->hw;
517 struct i40e_q_vector *q_vector; 519 struct i40e_q_vector *q_vector;
518 u16 vector; 520 u16 vector;
519 521
520 adapter->rx_rings[queue].rx_itr_setting = ec->rx_coalesce_usecs; 522 rx_ring->rx_itr_setting = ec->rx_coalesce_usecs;
521 adapter->tx_rings[queue].tx_itr_setting = ec->tx_coalesce_usecs; 523 tx_ring->tx_itr_setting = ec->tx_coalesce_usecs;
522 524
523 if (ec->use_adaptive_rx_coalesce) 525 rx_ring->rx_itr_setting |= I40E_ITR_DYNAMIC;
524 adapter->rx_rings[queue].rx_itr_setting |= I40E_ITR_DYNAMIC; 526 if (!ec->use_adaptive_rx_coalesce)
525 else 527 rx_ring->rx_itr_setting ^= I40E_ITR_DYNAMIC;
526 adapter->rx_rings[queue].rx_itr_setting &= ~I40E_ITR_DYNAMIC;
527 528
528 if (ec->use_adaptive_tx_coalesce) 529 tx_ring->tx_itr_setting |= I40E_ITR_DYNAMIC;
529 adapter->tx_rings[queue].tx_itr_setting |= I40E_ITR_DYNAMIC; 530 if (!ec->use_adaptive_tx_coalesce)
530 else 531 tx_ring->tx_itr_setting ^= I40E_ITR_DYNAMIC;
531 adapter->tx_rings[queue].tx_itr_setting &= ~I40E_ITR_DYNAMIC;
532 532
533 q_vector = adapter->rx_rings[queue].q_vector; 533 q_vector = rx_ring->q_vector;
534 q_vector->rx.itr = ITR_TO_REG(adapter->rx_rings[queue].rx_itr_setting); 534 q_vector->rx.itr = ITR_TO_REG(rx_ring->rx_itr_setting);
535 vector = vsi->base_vector + q_vector->v_idx; 535 vector = vsi->base_vector + q_vector->v_idx;
536 wr32(hw, I40E_VFINT_ITRN1(I40E_RX_ITR, vector - 1), q_vector->rx.itr); 536 wr32(hw, I40E_VFINT_ITRN1(I40E_RX_ITR, vector - 1), q_vector->rx.itr);
537 537
538 q_vector = adapter->tx_rings[queue].q_vector; 538 q_vector = tx_ring->q_vector;
539 q_vector->tx.itr = ITR_TO_REG(adapter->tx_rings[queue].tx_itr_setting); 539 q_vector->tx.itr = ITR_TO_REG(tx_ring->tx_itr_setting);
540 vector = vsi->base_vector + q_vector->v_idx; 540 vector = vsi->base_vector + q_vector->v_idx;
541 wr32(hw, I40E_VFINT_ITRN1(I40E_TX_ITR, vector - 1), q_vector->tx.itr); 541 wr32(hw, I40E_VFINT_ITRN1(I40E_TX_ITR, vector - 1), q_vector->tx.itr);
542 542
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 8934f784e96f..16989ad2ca90 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1387,6 +1387,7 @@ static int i40evf_alloc_q_vectors(struct i40evf_adapter *adapter)
1387 q_vector->adapter = adapter; 1387 q_vector->adapter = adapter;
1388 q_vector->vsi = &adapter->vsi; 1388 q_vector->vsi = &adapter->vsi;
1389 q_vector->v_idx = q_idx; 1389 q_vector->v_idx = q_idx;
1390 q_vector->reg_idx = q_idx;
1390 cpumask_copy(&q_vector->affinity_mask, cpu_possible_mask); 1391 cpumask_copy(&q_vector->affinity_mask, cpu_possible_mask);
1391 netif_napi_add(adapter->netdev, &q_vector->napi, 1392 netif_napi_add(adapter->netdev, &q_vector->napi,
1392 i40evf_napi_poll, NAPI_POLL_WEIGHT); 1393 i40evf_napi_poll, NAPI_POLL_WEIGHT);
@@ -2344,13 +2345,19 @@ static int i40evf_set_features(struct net_device *netdev,
2344{ 2345{
2345 struct i40evf_adapter *adapter = netdev_priv(netdev); 2346 struct i40evf_adapter *adapter = netdev_priv(netdev);
2346 2347
2347 if (!VLAN_ALLOWED(adapter)) 2348 /* Don't allow changing VLAN_RX flag when VLAN is set for VF
2349 * and return an error in this case
2350 */
2351 if (VLAN_ALLOWED(adapter)) {
2352 if (features & NETIF_F_HW_VLAN_CTAG_RX)
2353 adapter->aq_required |=
2354 I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
2355 else
2356 adapter->aq_required |=
2357 I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
2358 } else if ((netdev->features ^ features) & NETIF_F_HW_VLAN_CTAG_RX) {
2348 return -EINVAL; 2359 return -EINVAL;
2349 2360 }
2350 if (features & NETIF_F_HW_VLAN_CTAG_RX)
2351 adapter->aq_required |= I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
2352 else
2353 adapter->aq_required |= I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
2354 2361
2355 return 0; 2362 return 0;
2356} 2363}