aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-04-22 21:47:06 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-22 21:47:06 -0400
commitfd0d192be6e814495aec91f357b5801afc3b6262 (patch)
tree8c0ab850cea7cafad2786cf9f121ca109362cb3e
parenta29b694aa1739f9d76538e34ae25524f9c549d59 (diff)
parentb98d1df22af638f54221fa3af13432424fb9b4ac (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates This series contains updates to i40e and i40evf. Greg provides two patches for i40e, the first adds the netdev ops to support the addition of static FDB entries in the physical function (PF) MAC/VLAN filter table so that the virtual functions (VFs) can communicate with bridged virtual Ethernet ports such as those provided by the virtio driver. The second is to fix an issue where the assignment of a port VLAN after it is already up and running requires the VF driver to be reloaded, so print a message warning the host administrator about the need to reload the VF driver. In addition, knock the VF offline so that it does not continue to receive traffic not on the port VLAN assigned to it. Jesse provides a patch for i40e and i40evf to unhide and enable the PREFENA field in the receive host memory cache (RX-HMC) for best performance. Mitch provides a i40e patch to implement the net device op for Tx bandwidth setting. Catherine removes a firmware workaround that is no longer needed with the latest firmware for i40e. She also provides some minor cleanups as well bumps the driver versions. Anjali provides a fix for i40e displaying IPv4 flow director filters which needed additional information to be communicated up above in order for it to be displayed correctly. Shannon adds tracking of the NVM busy state so that the driver won't allow a new NVM update command until a completion event is received from the current update. Updates the admin queue API to reflect recent changes in the firmware. Also rearranges the "if netdev" logic to prepare for handling non-netdev VSIs. Lastly rework the fdir setup and tear down to use the newly created i40e_vsi_open() and i40e_vsi_close(), which also fixes a memory leak of the FDIR queue buffer info structs across a reset. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq.c23
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h41
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_common.c29
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c14
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c261
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_prototype.h3
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c93
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h1
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq.c22
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq.h1
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h41
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_lan_hmc.h1
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c2
16 files changed, 369 insertions, 166 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index ed3902bf249b..34415d342ece 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -33,6 +33,16 @@
33static void i40e_resume_aq(struct i40e_hw *hw); 33static void i40e_resume_aq(struct i40e_hw *hw);
34 34
35/** 35/**
36 * i40e_is_nvm_update_op - return true if this is an NVM update operation
37 * @desc: API request descriptor
38 **/
39static inline bool i40e_is_nvm_update_op(struct i40e_aq_desc *desc)
40{
41 return (desc->opcode == i40e_aqc_opc_nvm_erase) ||
42 (desc->opcode == i40e_aqc_opc_nvm_update);
43}
44
45/**
36 * i40e_adminq_init_regs - Initialize AdminQ registers 46 * i40e_adminq_init_regs - Initialize AdminQ registers
37 * @hw: pointer to the hardware structure 47 * @hw: pointer to the hardware structure
38 * 48 *
@@ -585,6 +595,7 @@ i40e_status i40e_init_adminq(struct i40e_hw *hw)
585 595
586 /* pre-emptive resource lock release */ 596 /* pre-emptive resource lock release */
587 i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL); 597 i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
598 hw->aq.nvm_busy = false;
588 599
589 ret_code = i40e_aq_set_hmc_resource_profile(hw, 600 ret_code = i40e_aq_set_hmc_resource_profile(hw,
590 I40E_HMC_PROFILE_DEFAULT, 601 I40E_HMC_PROFILE_DEFAULT,
@@ -708,6 +719,12 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
708 goto asq_send_command_exit; 719 goto asq_send_command_exit;
709 } 720 }
710 721
722 if (i40e_is_nvm_update_op(desc) && hw->aq.nvm_busy) {
723 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQTX: NVM busy.\n");
724 status = I40E_ERR_NVM;
725 goto asq_send_command_exit;
726 }
727
711 details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use); 728 details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
712 if (cmd_details) { 729 if (cmd_details) {
713 *details = *cmd_details; 730 *details = *cmd_details;
@@ -835,6 +852,9 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
835 hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval; 852 hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval;
836 } 853 }
837 854
855 if (i40e_is_nvm_update_op(desc))
856 hw->aq.nvm_busy = true;
857
838 /* update the error if time out occurred */ 858 /* update the error if time out occurred */
839 if ((!cmd_completed) && 859 if ((!cmd_completed) &&
840 (!details->async && !details->postpone)) { 860 (!details->async && !details->postpone)) {
@@ -929,6 +949,9 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
929 e->msg_size); 949 e->msg_size);
930 } 950 }
931 951
952 if (i40e_is_nvm_update_op(&e->desc))
953 hw->aq.nvm_busy = false;
954
932 /* Restore the original datalen and buffer address in the desc, 955 /* Restore the original datalen and buffer address in the desc,
933 * FW updates datalen to indicate the event message 956 * FW updates datalen to indicate the event message
934 * size 957 * size
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index 993f7685a911..b1552fbc48a0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -90,6 +90,7 @@ struct i40e_adminq_info {
90 u16 fw_min_ver; /* firmware minor version */ 90 u16 fw_min_ver; /* firmware minor version */
91 u16 api_maj_ver; /* api major version */ 91 u16 api_maj_ver; /* api major version */
92 u16 api_min_ver; /* api minor version */ 92 u16 api_min_ver; /* api minor version */
93 bool nvm_busy;
93 94
94 struct mutex asq_mutex; /* Send queue lock */ 95 struct mutex asq_mutex; /* Send queue lock */
95 struct mutex arq_mutex; /* Receive queue lock */ 96 struct mutex arq_mutex; /* Receive queue lock */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
index 7b6374a8f8da..f2ba4b76ecd3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
@@ -182,9 +182,6 @@ enum i40e_admin_queue_opc {
182 i40e_aqc_opc_add_mirror_rule = 0x0260, 182 i40e_aqc_opc_add_mirror_rule = 0x0260,
183 i40e_aqc_opc_delete_mirror_rule = 0x0261, 183 i40e_aqc_opc_delete_mirror_rule = 0x0261,
184 184
185 i40e_aqc_opc_set_storm_control_config = 0x0280,
186 i40e_aqc_opc_get_storm_control_config = 0x0281,
187
188 /* DCB commands */ 185 /* DCB commands */
189 i40e_aqc_opc_dcb_ignore_pfc = 0x0301, 186 i40e_aqc_opc_dcb_ignore_pfc = 0x0301,
190 i40e_aqc_opc_dcb_updated = 0x0302, 187 i40e_aqc_opc_dcb_updated = 0x0302,
@@ -207,6 +204,7 @@ enum i40e_admin_queue_opc {
207 i40e_aqc_opc_query_switching_comp_bw_config = 0x041A, 204 i40e_aqc_opc_query_switching_comp_bw_config = 0x041A,
208 i40e_aqc_opc_suspend_port_tx = 0x041B, 205 i40e_aqc_opc_suspend_port_tx = 0x041B,
209 i40e_aqc_opc_resume_port_tx = 0x041C, 206 i40e_aqc_opc_resume_port_tx = 0x041C,
207 i40e_aqc_opc_configure_partition_bw = 0x041D,
210 208
211 /* hmc */ 209 /* hmc */
212 i40e_aqc_opc_query_hmc_resource_profile = 0x0500, 210 i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
@@ -1289,27 +1287,6 @@ struct i40e_aqc_add_delete_mirror_rule_completion {
1289 1287
1290I40E_CHECK_CMD_LENGTH(i40e_aqc_add_delete_mirror_rule_completion); 1288I40E_CHECK_CMD_LENGTH(i40e_aqc_add_delete_mirror_rule_completion);
1291 1289
1292/* Set Storm Control Configuration (direct 0x0280)
1293 * Get Storm Control Configuration (direct 0x0281)
1294 * the command and response use the same descriptor structure
1295 */
1296struct i40e_aqc_set_get_storm_control_config {
1297 __le32 broadcast_threshold;
1298 __le32 multicast_threshold;
1299 __le32 control_flags;
1300#define I40E_AQC_STORM_CONTROL_MDIPW 0x01
1301#define I40E_AQC_STORM_CONTROL_MDICW 0x02
1302#define I40E_AQC_STORM_CONTROL_BDIPW 0x04
1303#define I40E_AQC_STORM_CONTROL_BDICW 0x08
1304#define I40E_AQC_STORM_CONTROL_BIDU 0x10
1305#define I40E_AQC_STORM_CONTROL_INTERVAL_SHIFT 8
1306#define I40E_AQC_STORM_CONTROL_INTERVAL_MASK (0x3FF << \
1307 I40E_AQC_STORM_CONTROL_INTERVAL_SHIFT)
1308 u8 reserved[4];
1309};
1310
1311I40E_CHECK_CMD_LENGTH(i40e_aqc_set_get_storm_control_config);
1312
1313/* DCB 0x03xx*/ 1290/* DCB 0x03xx*/
1314 1291
1315/* PFC Ignore (direct 0x0301) 1292/* PFC Ignore (direct 0x0301)
@@ -1499,6 +1476,15 @@ struct i40e_aqc_query_switching_comp_bw_config_resp {
1499 * (direct 0x041B and 0x041C) uses the generic SEID struct 1476 * (direct 0x041B and 0x041C) uses the generic SEID struct
1500 */ 1477 */
1501 1478
1479/* Configure partition BW
1480 * (indirect 0x041D)
1481 */
1482struct i40e_aqc_configure_partition_bw_data {
1483 __le16 pf_valid_bits;
1484 u8 min_bw[16]; /* guaranteed bandwidth */
1485 u8 max_bw[16]; /* bandwidth limit */
1486};
1487
1502/* Get and set the active HMC resource profile and status. 1488/* Get and set the active HMC resource profile and status.
1503 * (direct 0x0500) and (direct 0x0501) 1489 * (direct 0x0500) and (direct 0x0501)
1504 */ 1490 */
@@ -1583,11 +1569,8 @@ struct i40e_aq_get_phy_abilities_resp {
1583#define I40E_AQ_PHY_FLAG_PAUSE_TX 0x01 1569#define I40E_AQ_PHY_FLAG_PAUSE_TX 0x01
1584#define I40E_AQ_PHY_FLAG_PAUSE_RX 0x02 1570#define I40E_AQ_PHY_FLAG_PAUSE_RX 0x02
1585#define I40E_AQ_PHY_FLAG_LOW_POWER 0x04 1571#define I40E_AQ_PHY_FLAG_LOW_POWER 0x04
1586#define I40E_AQ_PHY_FLAG_AN_SHIFT 3 1572#define I40E_AQ_PHY_LINK_ENABLED 0x08
1587#define I40E_AQ_PHY_FLAG_AN_MASK (0x3 << I40E_AQ_PHY_FLAG_AN_SHIFT) 1573#define I40E_AQ_PHY_AN_ENABLED 0x10
1588#define I40E_AQ_PHY_FLAG_AN_OFF 0x00 /* link forced on */
1589#define I40E_AQ_PHY_FLAG_AN_OFF_LINK_DOWN 0x01
1590#define I40E_AQ_PHY_FLAG_AN_ON 0x02
1591#define I40E_AQ_PHY_FLAG_MODULE_QUAL 0x20 1574#define I40E_AQ_PHY_FLAG_MODULE_QUAL 0x20
1592 __le16 eee_capability; 1575 __le16 eee_capability;
1593#define I40E_AQ_EEE_100BASE_TX 0x0002 1576#define I40E_AQ_EEE_100BASE_TX 0x0002
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 922cdcc45c54..f8dfb4b7e99c 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -2253,6 +2253,35 @@ static i40e_status i40e_aq_tx_sched_cmd(struct i40e_hw *hw, u16 seid,
2253} 2253}
2254 2254
2255/** 2255/**
2256 * i40e_aq_config_vsi_bw_limit - Configure VSI BW Limit
2257 * @hw: pointer to the hw struct
2258 * @seid: VSI seid
2259 * @credit: BW limit credits (0 = disabled)
2260 * @max_credit: Max BW limit credits
2261 * @cmd_details: pointer to command details structure or NULL
2262 **/
2263i40e_status i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
2264 u16 seid, u16 credit, u8 max_credit,
2265 struct i40e_asq_cmd_details *cmd_details)
2266{
2267 struct i40e_aq_desc desc;
2268 struct i40e_aqc_configure_vsi_bw_limit *cmd =
2269 (struct i40e_aqc_configure_vsi_bw_limit *)&desc.params.raw;
2270 i40e_status status;
2271
2272 i40e_fill_default_direct_cmd_desc(&desc,
2273 i40e_aqc_opc_configure_vsi_bw_limit);
2274
2275 cmd->vsi_seid = cpu_to_le16(seid);
2276 cmd->credit = cpu_to_le16(credit);
2277 cmd->max_credit = max_credit;
2278
2279 status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
2280
2281 return status;
2282}
2283
2284/**
2256 * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC 2285 * i40e_aq_config_vsi_tc_bw - Config VSI BW Allocation per TC
2257 * @hw: pointer to the hw struct 2286 * @hw: pointer to the hw struct
2258 * @seid: VSI seid 2287 * @seid: VSI seid
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 03d99cbc5c25..0cf47c958081 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -649,7 +649,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
649 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; 649 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
650 } 650 }
651 rcu_read_lock(); 651 rcu_read_lock();
652 for (j = 0; j < vsi->num_queue_pairs; j++, i += 4) { 652 for (j = 0; j < vsi->num_queue_pairs; j++) {
653 struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[j]); 653 struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
654 struct i40e_ring *rx_ring; 654 struct i40e_ring *rx_ring;
655 655
@@ -662,14 +662,16 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
662 data[i] = tx_ring->stats.packets; 662 data[i] = tx_ring->stats.packets;
663 data[i + 1] = tx_ring->stats.bytes; 663 data[i + 1] = tx_ring->stats.bytes;
664 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start)); 664 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
665 i += 2;
665 666
666 /* Rx ring is the 2nd half of the queue pair */ 667 /* Rx ring is the 2nd half of the queue pair */
667 rx_ring = &tx_ring[1]; 668 rx_ring = &tx_ring[1];
668 do { 669 do {
669 start = u64_stats_fetch_begin_irq(&rx_ring->syncp); 670 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
670 data[i + 2] = rx_ring->stats.packets; 671 data[i] = rx_ring->stats.packets;
671 data[i + 3] = rx_ring->stats.bytes; 672 data[i + 1] = rx_ring->stats.bytes;
672 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); 673 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
674 i += 2;
673 } 675 }
674 rcu_read_unlock(); 676 rcu_read_unlock();
675 if (vsi == pf->vsi[pf->lan_vsi]) { 677 if (vsi == pf->vsi[pf->lan_vsi]) {
@@ -1189,6 +1191,12 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
1189 return -EINVAL; 1191 return -EINVAL;
1190 1192
1191 fsp->flow_type = rule->flow_type; 1193 fsp->flow_type = rule->flow_type;
1194 if (fsp->flow_type == IP_USER_FLOW) {
1195 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
1196 fsp->h_u.usr_ip4_spec.proto = 0;
1197 fsp->m_u.usr_ip4_spec.proto = 0;
1198 }
1199
1192 fsp->h_u.tcp_ip4_spec.psrc = rule->src_port; 1200 fsp->h_u.tcp_ip4_spec.psrc = rule->src_port;
1193 fsp->h_u.tcp_ip4_spec.pdst = rule->dst_port; 1201 fsp->h_u.tcp_ip4_spec.pdst = rule->dst_port;
1194 fsp->h_u.tcp_ip4_spec.ip4src = rule->src_ip[0]; 1202 fsp->h_u.tcp_ip4_spec.ip4src = rule->src_ip[0];
diff --git a/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c b/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c
index d5d98fe2691d..5c341aeb5d53 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c
@@ -747,6 +747,7 @@ static struct i40e_context_ele i40e_hmc_rxq_ce_info[] = {
747 { I40E_HMC_STORE(i40e_hmc_obj_rxq, tphdata_ena), 1, 195 }, 747 { I40E_HMC_STORE(i40e_hmc_obj_rxq, tphdata_ena), 1, 195 },
748 { I40E_HMC_STORE(i40e_hmc_obj_rxq, tphhead_ena), 1, 196 }, 748 { I40E_HMC_STORE(i40e_hmc_obj_rxq, tphhead_ena), 1, 196 },
749 { I40E_HMC_STORE(i40e_hmc_obj_rxq, lrxqthresh), 3, 198 }, 749 { I40E_HMC_STORE(i40e_hmc_obj_rxq, lrxqthresh), 3, 198 },
750 { I40E_HMC_STORE(i40e_hmc_obj_rxq, prefena), 1, 201 },
750 { 0 } 751 { 0 }
751}; 752};
752 753
diff --git a/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h b/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h
index 341de925a298..eb65fe23c4a7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h
@@ -56,6 +56,7 @@ struct i40e_hmc_obj_rxq {
56 u8 tphdata_ena; 56 u8 tphdata_ena;
57 u8 tphhead_ena; 57 u8 tphhead_ena;
58 u8 lrxqthresh; 58 u8 lrxqthresh;
59 u8 prefena; /* NOTE: normally must be set to 1 at init */
59}; 60};
60 61
61/* Tx queue context data */ 62/* Tx queue context data */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 861b722c2672..0c69851eaecc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -39,7 +39,7 @@ static const char i40e_driver_string[] =
39 39
40#define DRV_VERSION_MAJOR 0 40#define DRV_VERSION_MAJOR 0
41#define DRV_VERSION_MINOR 3 41#define DRV_VERSION_MINOR 3
42#define DRV_VERSION_BUILD 36 42#define DRV_VERSION_BUILD 43
43#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ 43#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
44 __stringify(DRV_VERSION_MINOR) "." \ 44 __stringify(DRV_VERSION_MINOR) "." \
45 __stringify(DRV_VERSION_BUILD) DRV_KERN 45 __stringify(DRV_VERSION_BUILD) DRV_KERN
@@ -2312,6 +2312,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
2312 rx_ctx.crcstrip = 1; 2312 rx_ctx.crcstrip = 1;
2313 rx_ctx.l2tsel = 1; 2313 rx_ctx.l2tsel = 1;
2314 rx_ctx.showiv = 1; 2314 rx_ctx.showiv = 1;
2315 /* set the prefena field to 1 because the manual says to */
2316 rx_ctx.prefena = 1;
2315 2317
2316 /* clear the context in the HMC */ 2318 /* clear the context in the HMC */
2317 err = i40e_clear_lan_rx_queue_context(hw, pf_q); 2319 err = i40e_clear_lan_rx_queue_context(hw, pf_q);
@@ -3163,9 +3165,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3163 usleep_range(1000, 2000); 3165 usleep_range(1000, 2000);
3164 } 3166 }
3165 /* Skip if the queue is already in the requested state */ 3167 /* Skip if the queue is already in the requested state */
3166 if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) 3168 if (enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3167 continue;
3168 if (!enable && !(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3169 continue; 3169 continue;
3170 3170
3171 /* turn on/off the queue */ 3171 /* turn on/off the queue */
@@ -3181,13 +3181,8 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3181 /* wait for the change to finish */ 3181 /* wait for the change to finish */
3182 for (j = 0; j < 10; j++) { 3182 for (j = 0; j < 10; j++) {
3183 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); 3183 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q));
3184 if (enable) { 3184 if (enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3185 if ((tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) 3185 break;
3186 break;
3187 } else {
3188 if (!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3189 break;
3190 }
3191 3186
3192 udelay(10); 3187 udelay(10);
3193 } 3188 }
@@ -3226,15 +3221,9 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3226 usleep_range(1000, 2000); 3221 usleep_range(1000, 2000);
3227 } 3222 }
3228 3223
3229 if (enable) { 3224 /* Skip if the queue is already in the requested state */
3230 /* is STAT set ? */ 3225 if (enable == !!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3231 if ((rx_reg & I40E_QRX_ENA_QENA_STAT_MASK)) 3226 continue;
3232 continue;
3233 } else {
3234 /* is !STAT set ? */
3235 if (!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3236 continue;
3237 }
3238 3227
3239 /* turn on/off the queue */ 3228 /* turn on/off the queue */
3240 if (enable) 3229 if (enable)
@@ -3247,13 +3236,8 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3247 for (j = 0; j < 10; j++) { 3236 for (j = 0; j < 10; j++) {
3248 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q)); 3237 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q));
3249 3238
3250 if (enable) { 3239 if (enable == !!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3251 if ((rx_reg & I40E_QRX_ENA_QENA_STAT_MASK)) 3240 break;
3252 break;
3253 } else {
3254 if (!(rx_reg & I40E_QRX_ENA_QENA_STAT_MASK))
3255 break;
3256 }
3257 3241
3258 udelay(10); 3242 udelay(10);
3259 } 3243 }
@@ -3516,6 +3500,19 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi)
3516} 3500}
3517 3501
3518/** 3502/**
3503 * i40e_vsi_close - Shut down a VSI
3504 * @vsi: the vsi to be quelled
3505 **/
3506static void i40e_vsi_close(struct i40e_vsi *vsi)
3507{
3508 if (!test_and_set_bit(__I40E_DOWN, &vsi->state))
3509 i40e_down(vsi);
3510 i40e_vsi_free_irq(vsi);
3511 i40e_vsi_free_tx_resources(vsi);
3512 i40e_vsi_free_rx_resources(vsi);
3513}
3514
3515/**
3519 * i40e_quiesce_vsi - Pause a given VSI 3516 * i40e_quiesce_vsi - Pause a given VSI
3520 * @vsi: the VSI being paused 3517 * @vsi: the VSI being paused
3521 **/ 3518 **/
@@ -3528,8 +3525,7 @@ static void i40e_quiesce_vsi(struct i40e_vsi *vsi)
3528 if (vsi->netdev && netif_running(vsi->netdev)) { 3525 if (vsi->netdev && netif_running(vsi->netdev)) {
3529 vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 3526 vsi->netdev->netdev_ops->ndo_stop(vsi->netdev);
3530 } else { 3527 } else {
3531 set_bit(__I40E_DOWN, &vsi->state); 3528 i40e_vsi_close(vsi);
3532 i40e_down(vsi);
3533 } 3529 }
3534} 3530}
3535 3531
@@ -3546,7 +3542,7 @@ static void i40e_unquiesce_vsi(struct i40e_vsi *vsi)
3546 if (vsi->netdev && netif_running(vsi->netdev)) 3542 if (vsi->netdev && netif_running(vsi->netdev))
3547 vsi->netdev->netdev_ops->ndo_open(vsi->netdev); 3543 vsi->netdev->netdev_ops->ndo_open(vsi->netdev);
3548 else 3544 else
3549 i40e_up(vsi); /* this clears the DOWN bit */ 3545 i40e_vsi_open(vsi); /* this clears the DOWN bit */
3550} 3546}
3551 3547
3552/** 3548/**
@@ -4304,24 +4300,32 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
4304 if (err) 4300 if (err)
4305 goto err_setup_rx; 4301 goto err_setup_rx;
4306 4302
4307 if (!vsi->netdev) { 4303 if (vsi->netdev) {
4304 snprintf(int_name, sizeof(int_name) - 1, "%s-%s",
4305 dev_driver_string(&pf->pdev->dev), vsi->netdev->name);
4306 err = i40e_vsi_request_irq(vsi, int_name);
4307 if (err)
4308 goto err_setup_rx;
4309
4310 /* Notify the stack of the actual queue counts. */
4311 err = netif_set_real_num_tx_queues(vsi->netdev,
4312 vsi->num_queue_pairs);
4313 if (err)
4314 goto err_set_queues;
4315
4316 err = netif_set_real_num_rx_queues(vsi->netdev,
4317 vsi->num_queue_pairs);
4318 if (err)
4319 goto err_set_queues;
4320
4321 } else if (vsi->type == I40E_VSI_FDIR) {
4322 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
4323 dev_driver_string(&pf->pdev->dev));
4324 err = i40e_vsi_request_irq(vsi, int_name);
4325 } else {
4308 err = EINVAL; 4326 err = EINVAL;
4309 goto err_setup_rx; 4327 goto err_setup_rx;
4310 } 4328 }
4311 snprintf(int_name, sizeof(int_name) - 1, "%s-%s",
4312 dev_driver_string(&pf->pdev->dev), vsi->netdev->name);
4313 err = i40e_vsi_request_irq(vsi, int_name);
4314 if (err)
4315 goto err_setup_rx;
4316
4317 /* Notify the stack of the actual queue counts. */
4318 err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_queue_pairs);
4319 if (err)
4320 goto err_set_queues;
4321
4322 err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_queue_pairs);
4323 if (err)
4324 goto err_set_queues;
4325 4329
4326 err = i40e_up_complete(vsi); 4330 err = i40e_up_complete(vsi);
4327 if (err) 4331 if (err)
@@ -4378,14 +4382,7 @@ static int i40e_close(struct net_device *netdev)
4378 struct i40e_netdev_priv *np = netdev_priv(netdev); 4382 struct i40e_netdev_priv *np = netdev_priv(netdev);
4379 struct i40e_vsi *vsi = np->vsi; 4383 struct i40e_vsi *vsi = np->vsi;
4380 4384
4381 if (test_and_set_bit(__I40E_DOWN, &vsi->state)) 4385 i40e_vsi_close(vsi);
4382 return 0;
4383
4384 i40e_down(vsi);
4385 i40e_vsi_free_irq(vsi);
4386
4387 i40e_vsi_free_tx_resources(vsi);
4388 i40e_vsi_free_rx_resources(vsi);
4389 4386
4390 return 0; 4387 return 0;
4391} 4388}
@@ -5221,9 +5218,6 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
5221 } 5218 }
5222 } while (err); 5219 } while (err);
5223 5220
5224 /* increment MSI-X count because current FW skips one */
5225 pf->hw.func_caps.num_msix_vectors++;
5226
5227 if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) || 5221 if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) ||
5228 (pf->hw.aq.fw_maj_ver < 2)) { 5222 (pf->hw.aq.fw_maj_ver < 2)) {
5229 pf->hw.func_caps.num_msix_vectors++; 5223 pf->hw.func_caps.num_msix_vectors++;
@@ -5262,8 +5256,7 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi);
5262static void i40e_fdir_sb_setup(struct i40e_pf *pf) 5256static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5263{ 5257{
5264 struct i40e_vsi *vsi; 5258 struct i40e_vsi *vsi;
5265 bool new_vsi = false; 5259 int i;
5266 int err, i;
5267 5260
5268 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) 5261 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
5269 return; 5262 return;
@@ -5283,47 +5276,12 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5283 pf->vsi[pf->lan_vsi]->seid, 0); 5276 pf->vsi[pf->lan_vsi]->seid, 0);
5284 if (!vsi) { 5277 if (!vsi) {
5285 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n"); 5278 dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n");
5286 goto err_vsi; 5279 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
5280 return;
5287 } 5281 }
5288 new_vsi = true;
5289 }
5290 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
5291
5292 err = i40e_vsi_setup_tx_resources(vsi);
5293 if (err)
5294 goto err_setup_tx;
5295 err = i40e_vsi_setup_rx_resources(vsi);
5296 if (err)
5297 goto err_setup_rx;
5298
5299 if (new_vsi) {
5300 char int_name[IFNAMSIZ + 9];
5301 err = i40e_vsi_configure(vsi);
5302 if (err)
5303 goto err_setup_rx;
5304 snprintf(int_name, sizeof(int_name) - 1, "%s-fdir",
5305 dev_driver_string(&pf->pdev->dev));
5306 err = i40e_vsi_request_irq(vsi, int_name);
5307 if (err)
5308 goto err_setup_rx;
5309 err = i40e_up_complete(vsi);
5310 if (err)
5311 goto err_up_complete;
5312 clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
5313 } 5282 }
5314 5283
5315 return; 5284 i40e_vsi_setup_irqhandler(vsi, i40e_fdir_clean_ring);
5316
5317err_up_complete:
5318 i40e_down(vsi);
5319 i40e_vsi_free_irq(vsi);
5320err_setup_rx:
5321 i40e_vsi_free_rx_resources(vsi);
5322err_setup_tx:
5323 i40e_vsi_free_tx_resources(vsi);
5324err_vsi:
5325 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
5326 i40e_vsi_clear(vsi);
5327} 5285}
5328 5286
5329/** 5287/**
@@ -6644,6 +6602,96 @@ static void i40e_del_vxlan_port(struct net_device *netdev,
6644} 6602}
6645 6603
6646#endif 6604#endif
6605#ifdef HAVE_FDB_OPS
6606#ifdef USE_CONST_DEV_UC_CHAR
6607static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
6608 struct net_device *dev,
6609 const unsigned char *addr,
6610 u16 flags)
6611#else
6612static int i40e_ndo_fdb_add(struct ndmsg *ndm,
6613 struct net_device *dev,
6614 unsigned char *addr,
6615 u16 flags)
6616#endif
6617{
6618 struct i40e_netdev_priv *np = netdev_priv(dev);
6619 struct i40e_pf *pf = np->vsi->back;
6620 int err = 0;
6621
6622 if (!(pf->flags & I40E_FLAG_SRIOV_ENABLED))
6623 return -EOPNOTSUPP;
6624
6625 /* Hardware does not support aging addresses so if a
6626 * ndm_state is given only allow permanent addresses
6627 */
6628 if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
6629 netdev_info(dev, "FDB only supports static addresses\n");
6630 return -EINVAL;
6631 }
6632
6633 if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
6634 err = dev_uc_add_excl(dev, addr);
6635 else if (is_multicast_ether_addr(addr))
6636 err = dev_mc_add_excl(dev, addr);
6637 else
6638 err = -EINVAL;
6639
6640 /* Only return duplicate errors if NLM_F_EXCL is set */
6641 if (err == -EEXIST && !(flags & NLM_F_EXCL))
6642 err = 0;
6643
6644 return err;
6645}
6646
6647#ifndef USE_DEFAULT_FDB_DEL_DUMP
6648#ifdef USE_CONST_DEV_UC_CHAR
6649static int i40e_ndo_fdb_del(struct ndmsg *ndm,
6650 struct net_device *dev,
6651 const unsigned char *addr)
6652#else
6653static int i40e_ndo_fdb_del(struct ndmsg *ndm,
6654 struct net_device *dev,
6655 unsigned char *addr)
6656#endif
6657{
6658 struct i40e_netdev_priv *np = netdev_priv(dev);
6659 struct i40e_pf *pf = np->vsi->back;
6660 int err = -EOPNOTSUPP;
6661
6662 if (ndm->ndm_state & NUD_PERMANENT) {
6663 netdev_info(dev, "FDB only supports static addresses\n");
6664 return -EINVAL;
6665 }
6666
6667 if (pf->flags & I40E_FLAG_SRIOV_ENABLED) {
6668 if (is_unicast_ether_addr(addr))
6669 err = dev_uc_del(dev, addr);
6670 else if (is_multicast_ether_addr(addr))
6671 err = dev_mc_del(dev, addr);
6672 else
6673 err = -EINVAL;
6674 }
6675
6676 return err;
6677}
6678
6679static int i40e_ndo_fdb_dump(struct sk_buff *skb,
6680 struct netlink_callback *cb,
6681 struct net_device *dev,
6682 int idx)
6683{
6684 struct i40e_netdev_priv *np = netdev_priv(dev);
6685 struct i40e_pf *pf = np->vsi->back;
6686
6687 if (pf->flags & I40E_FLAG_SRIOV_ENABLED)
6688 idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
6689
6690 return idx;
6691}
6692
6693#endif /* USE_DEFAULT_FDB_DEL_DUMP */
6694#endif /* HAVE_FDB_OPS */
6647static const struct net_device_ops i40e_netdev_ops = { 6695static const struct net_device_ops i40e_netdev_ops = {
6648 .ndo_open = i40e_open, 6696 .ndo_open = i40e_open,
6649 .ndo_stop = i40e_close, 6697 .ndo_stop = i40e_close,
@@ -6671,6 +6719,13 @@ static const struct net_device_ops i40e_netdev_ops = {
6671 .ndo_add_vxlan_port = i40e_add_vxlan_port, 6719 .ndo_add_vxlan_port = i40e_add_vxlan_port,
6672 .ndo_del_vxlan_port = i40e_del_vxlan_port, 6720 .ndo_del_vxlan_port = i40e_del_vxlan_port,
6673#endif 6721#endif
6722#ifdef HAVE_FDB_OPS
6723 .ndo_fdb_add = i40e_ndo_fdb_add,
6724#ifndef USE_DEFAULT_FDB_DEL_DUMP
6725 .ndo_fdb_del = i40e_ndo_fdb_del,
6726 .ndo_fdb_dump = i40e_ndo_fdb_dump,
6727#endif
6728#endif
6674}; 6729};
6675 6730
6676/** 6731/**
@@ -6976,11 +7031,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
6976 unregister_netdev(vsi->netdev); 7031 unregister_netdev(vsi->netdev);
6977 } 7032 }
6978 } else { 7033 } else {
6979 if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) 7034 i40e_vsi_close(vsi);
6980 i40e_down(vsi);
6981 i40e_vsi_free_irq(vsi);
6982 i40e_vsi_free_tx_resources(vsi);
6983 i40e_vsi_free_rx_resources(vsi);
6984 } 7035 }
6985 i40e_vsi_disable_irq(vsi); 7036 i40e_vsi_disable_irq(vsi);
6986 } 7037 }
@@ -8084,6 +8135,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8084 u16 link_status; 8135 u16 link_status;
8085 int err = 0; 8136 int err = 0;
8086 u32 len; 8137 u32 len;
8138 u32 i;
8087 8139
8088 err = pci_enable_device_mem(pdev); 8140 err = pci_enable_device_mem(pdev);
8089 if (err) 8141 if (err)
@@ -8273,6 +8325,13 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8273 dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err); 8325 dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
8274 goto err_vsis; 8326 goto err_vsis;
8275 } 8327 }
8328 /* if FDIR VSI was set up, start it now */
8329 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) {
8330 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
8331 i40e_vsi_open(pf->vsi[i]);
8332 break;
8333 }
8334 }
8276 8335
8277 /* The main driver is (mostly) up and happy. We need to set this state 8336 /* The main driver is (mostly) up and happy. We need to set this state
8278 * before setting up the misc vector or we get a race and the vector 8337 * before setting up the misc vector or we get a race and the vector
diff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
index 9cd57e617959..10652f615aec 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
@@ -167,6 +167,9 @@ i40e_status i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
167i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, 167i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw,
168 u16 flags, u8 *mac_addr, 168 u16 flags, u8 *mac_addr,
169 struct i40e_asq_cmd_details *cmd_details); 169 struct i40e_asq_cmd_details *cmd_details);
170i40e_status i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
171 u16 seid, u16 credit, u8 max_credit,
172 struct i40e_asq_cmd_details *cmd_details);
170i40e_status i40e_aq_dcb_updated(struct i40e_hw *hw, 173i40e_status i40e_aq_dcb_updated(struct i40e_hw *hw,
171 struct i40e_asq_cmd_details *cmd_details); 174 struct i40e_asq_cmd_details *cmd_details);
172i40e_status i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw, 175i40e_status i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 02c11a7f7d29..5421714df324 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -29,6 +29,24 @@
29/***********************misc routines*****************************/ 29/***********************misc routines*****************************/
30 30
31/** 31/**
32 * i40e_vc_disable_vf
33 * @pf: pointer to the pf info
34 * @vf: pointer to the vf info
35 *
36 * Disable the VF through a SW reset
37 **/
38static inline void i40e_vc_disable_vf(struct i40e_pf *pf, struct i40e_vf *vf)
39{
40 struct i40e_hw *hw = &pf->hw;
41 u32 reg;
42
43 reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id));
44 reg |= I40E_VPGEN_VFRTRIG_VFSWR_MASK;
45 wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg);
46 i40e_flush(hw);
47}
48
49/**
32 * i40e_vc_isvalid_vsi_id 50 * i40e_vc_isvalid_vsi_id
33 * @vf: pointer to the vf info 51 * @vf: pointer to the vf info
34 * @vsi_id: vf relative vsi id 52 * @vsi_id: vf relative vsi id
@@ -416,6 +434,15 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
416 if (ret) 434 if (ret)
417 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n"); 435 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n");
418 436
437 /* Set VF bandwidth if specified */
438 if (vf->tx_rate) {
439 ret = i40e_aq_config_vsi_bw_limit(&pf->hw, vsi->seid,
440 vf->tx_rate / 50, 0, NULL);
441 if (ret)
442 dev_err(&pf->pdev->dev, "Unable to set tx rate, VF %d, error code %d.\n",
443 vf->vf_id, ret);
444 }
445
419error_alloc_vsi_res: 446error_alloc_vsi_res:
420 return ret; 447 return ret;
421} 448}
@@ -2088,10 +2115,16 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
2088 goto error_pvid; 2115 goto error_pvid;
2089 } 2116 }
2090 2117
2091 if (vsi->info.pvid == 0 && i40e_is_vsi_in_vlan(vsi)) 2118 if (vsi->info.pvid == 0 && i40e_is_vsi_in_vlan(vsi)) {
2092 dev_err(&pf->pdev->dev, 2119 dev_err(&pf->pdev->dev,
2093 "VF %d has already configured VLAN filters and the administrator is requesting a port VLAN override.\nPlease unload and reload the VF driver for this change to take effect.\n", 2120 "VF %d has already configured VLAN filters and the administrator is requesting a port VLAN override.\nPlease unload and reload the VF driver for this change to take effect.\n",
2094 vf_id); 2121 vf_id);
2122 /* Administrator Error - knock the VF offline until he does
2123 * the right thing by reconfiguring his network correctly
2124 * and then reloading the VF driver.
2125 */
2126 i40e_vc_disable_vf(pf, vf);
2127 }
2095 2128
2096 /* Check for condition where there was already a port VLAN ID 2129 /* Check for condition where there was already a port VLAN ID
2097 * filter set and now it is being deleted by setting it to zero. 2130 * filter set and now it is being deleted by setting it to zero.
@@ -2160,7 +2193,61 @@ error_pvid:
2160 **/ 2193 **/
2161int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate) 2194int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate)
2162{ 2195{
2163 return -EOPNOTSUPP; 2196 struct i40e_netdev_priv *np = netdev_priv(netdev);
2197 struct i40e_pf *pf = np->vsi->back;
2198 struct i40e_vsi *vsi;
2199 struct i40e_vf *vf;
2200 int speed = 0;
2201 int ret = 0;
2202
2203 /* validate the request */
2204 if (vf_id >= pf->num_alloc_vfs) {
2205 dev_err(&pf->pdev->dev, "Invalid VF Identifier %d.\n", vf_id);
2206 ret = -EINVAL;
2207 goto error;
2208 }
2209
2210 vf = &(pf->vf[vf_id]);
2211 vsi = pf->vsi[vf->lan_vsi_index];
2212 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
2213 dev_err(&pf->pdev->dev, "Uninitialized VF %d.\n", vf_id);
2214 ret = -EINVAL;
2215 goto error;
2216 }
2217
2218 switch (pf->hw.phy.link_info.link_speed) {
2219 case I40E_LINK_SPEED_40GB:
2220 speed = 40000;
2221 break;
2222 case I40E_LINK_SPEED_10GB:
2223 speed = 10000;
2224 break;
2225 case I40E_LINK_SPEED_1GB:
2226 speed = 1000;
2227 break;
2228 default:
2229 break;
2230 }
2231
2232 if (tx_rate > speed) {
2233 dev_err(&pf->pdev->dev, "Invalid tx rate %d specified for vf %d.",
2234 tx_rate, vf->vf_id);
2235 ret = -EINVAL;
2236 goto error;
2237 }
2238
2239 /* Tx rate credits are in values of 50Mbps, 0 is disabled*/
2240 ret = i40e_aq_config_vsi_bw_limit(&pf->hw, vsi->seid, tx_rate / 50, 0,
2241 NULL);
2242 if (ret) {
2243 dev_err(&pf->pdev->dev, "Unable to set tx rate, error code %d.\n",
2244 ret);
2245 ret = -EIO;
2246 goto error;
2247 }
2248 vf->tx_rate = tx_rate;
2249error:
2250 return ret;
2164} 2251}
2165 2252
2166/** 2253/**
@@ -2200,7 +2287,7 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
2200 2287
2201 memcpy(&ivi->mac, vf->default_lan_addr.addr, ETH_ALEN); 2288 memcpy(&ivi->mac, vf->default_lan_addr.addr, ETH_ALEN);
2202 2289
2203 ivi->tx_rate = 0; 2290 ivi->tx_rate = vf->tx_rate;
2204 ivi->vlan = le16_to_cpu(vsi->info.pvid) & I40E_VLAN_MASK; 2291 ivi->vlan = le16_to_cpu(vsi->info.pvid) & I40E_VLAN_MASK;
2205 ivi->qos = (le16_to_cpu(vsi->info.pvid) & I40E_PRIORITY_MASK) >> 2292 ivi->qos = (le16_to_cpu(vsi->info.pvid) & I40E_PRIORITY_MASK) >>
2206 I40E_VLAN_PRIORITY_SHIFT; 2293 I40E_VLAN_PRIORITY_SHIFT;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
index 389c47f396d5..ba3d1f8414be 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
@@ -98,6 +98,7 @@ struct i40e_vf {
98 98
99 unsigned long vf_caps; /* vf's adv. capabilities */ 99 unsigned long vf_caps; /* vf's adv. capabilities */
100 unsigned long vf_states; /* vf's runtime states */ 100 unsigned long vf_states; /* vf's runtime states */
101 unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
101 bool link_forced; 102 bool link_forced;
102 bool link_up; /* only valid if vf link is forced */ 103 bool link_up; /* only valid if vf link is forced */
103}; 104};
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
index 5470ce95936e..c79df257f830 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c
@@ -28,6 +28,16 @@
28#include "i40e_prototype.h" 28#include "i40e_prototype.h"
29 29
30/** 30/**
31 * i40e_is_nvm_update_op - return true if this is an NVM update operation
32 * @desc: API request descriptor
33 **/
34static inline bool i40e_is_nvm_update_op(struct i40e_aq_desc *desc)
35{
36 return (desc->opcode == i40e_aqc_opc_nvm_erase) ||
37 (desc->opcode == i40e_aqc_opc_nvm_update);
38}
39
40/**
31 * i40e_adminq_init_regs - Initialize AdminQ registers 41 * i40e_adminq_init_regs - Initialize AdminQ registers
32 * @hw: pointer to the hardware structure 42 * @hw: pointer to the hardware structure
33 * 43 *
@@ -659,6 +669,12 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
659 goto asq_send_command_exit; 669 goto asq_send_command_exit;
660 } 670 }
661 671
672 if (i40e_is_nvm_update_op(desc) && hw->aq.nvm_busy) {
673 i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQTX: NVM busy.\n");
674 status = I40E_ERR_NVM;
675 goto asq_send_command_exit;
676 }
677
662 details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use); 678 details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
663 if (cmd_details) { 679 if (cmd_details) {
664 *details = *cmd_details; 680 *details = *cmd_details;
@@ -786,6 +802,9 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
786 hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval; 802 hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval;
787 } 803 }
788 804
805 if (i40e_is_nvm_update_op(desc))
806 hw->aq.nvm_busy = true;
807
789 /* update the error if time out occurred */ 808 /* update the error if time out occurred */
790 if ((!cmd_completed) && 809 if ((!cmd_completed) &&
791 (!details->async && !details->postpone)) { 810 (!details->async && !details->postpone)) {
@@ -880,6 +899,9 @@ i40e_status i40evf_clean_arq_element(struct i40e_hw *hw,
880 e->msg_size); 899 e->msg_size);
881 } 900 }
882 901
902 if (i40e_is_nvm_update_op(&e->desc))
903 hw->aq.nvm_busy = false;
904
883 /* Restore the original datalen and buffer address in the desc, 905 /* Restore the original datalen and buffer address in the desc,
884 * FW updates datalen to indicate the event message 906 * FW updates datalen to indicate the event message
885 * size 907 * size
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
index 8f72c31d95cc..7d24be528601 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
@@ -87,6 +87,7 @@ struct i40e_adminq_info {
87 u16 fw_min_ver; /* firmware minor version */ 87 u16 fw_min_ver; /* firmware minor version */
88 u16 api_maj_ver; /* api major version */ 88 u16 api_maj_ver; /* api major version */
89 u16 api_min_ver; /* api minor version */ 89 u16 api_min_ver; /* api minor version */
90 bool nvm_busy;
90 91
91 struct mutex asq_mutex; /* Send queue lock */ 92 struct mutex asq_mutex; /* Send queue lock */
92 struct mutex arq_mutex; /* Receive queue lock */ 93 struct mutex arq_mutex; /* Receive queue lock */
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
index 97662b6bd98a..6e617669c326 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
@@ -180,9 +180,6 @@ enum i40e_admin_queue_opc {
180 i40e_aqc_opc_add_mirror_rule = 0x0260, 180 i40e_aqc_opc_add_mirror_rule = 0x0260,
181 i40e_aqc_opc_delete_mirror_rule = 0x0261, 181 i40e_aqc_opc_delete_mirror_rule = 0x0261,
182 182
183 i40e_aqc_opc_set_storm_control_config = 0x0280,
184 i40e_aqc_opc_get_storm_control_config = 0x0281,
185
186 /* DCB commands */ 183 /* DCB commands */
187 i40e_aqc_opc_dcb_ignore_pfc = 0x0301, 184 i40e_aqc_opc_dcb_ignore_pfc = 0x0301,
188 i40e_aqc_opc_dcb_updated = 0x0302, 185 i40e_aqc_opc_dcb_updated = 0x0302,
@@ -205,6 +202,7 @@ enum i40e_admin_queue_opc {
205 i40e_aqc_opc_query_switching_comp_bw_config = 0x041A, 202 i40e_aqc_opc_query_switching_comp_bw_config = 0x041A,
206 i40e_aqc_opc_suspend_port_tx = 0x041B, 203 i40e_aqc_opc_suspend_port_tx = 0x041B,
207 i40e_aqc_opc_resume_port_tx = 0x041C, 204 i40e_aqc_opc_resume_port_tx = 0x041C,
205 i40e_aqc_opc_configure_partition_bw = 0x041D,
208 206
209 /* hmc */ 207 /* hmc */
210 i40e_aqc_opc_query_hmc_resource_profile = 0x0500, 208 i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
@@ -1289,27 +1287,6 @@ struct i40e_aqc_add_delete_mirror_rule_completion {
1289 1287
1290I40E_CHECK_CMD_LENGTH(i40e_aqc_add_delete_mirror_rule_completion); 1288I40E_CHECK_CMD_LENGTH(i40e_aqc_add_delete_mirror_rule_completion);
1291 1289
1292/* Set Storm Control Configuration (direct 0x0280)
1293 * Get Storm Control Configuration (direct 0x0281)
1294 * the command and response use the same descriptor structure
1295 */
1296struct i40e_aqc_set_get_storm_control_config {
1297 __le32 broadcast_threshold;
1298 __le32 multicast_threshold;
1299 __le32 control_flags;
1300#define I40E_AQC_STORM_CONTROL_MDIPW 0x01
1301#define I40E_AQC_STORM_CONTROL_MDICW 0x02
1302#define I40E_AQC_STORM_CONTROL_BDIPW 0x04
1303#define I40E_AQC_STORM_CONTROL_BDICW 0x08
1304#define I40E_AQC_STORM_CONTROL_BIDU 0x10
1305#define I40E_AQC_STORM_CONTROL_INTERVAL_SHIFT 8
1306#define I40E_AQC_STORM_CONTROL_INTERVAL_MASK (0x3FF << \
1307 I40E_AQC_STORM_CONTROL_INTERVAL_SHIFT)
1308 u8 reserved[4];
1309};
1310
1311I40E_CHECK_CMD_LENGTH(i40e_aqc_set_get_storm_control_config);
1312
1313/* DCB 0x03xx*/ 1290/* DCB 0x03xx*/
1314 1291
1315/* PFC Ignore (direct 0x0301) 1292/* PFC Ignore (direct 0x0301)
@@ -1499,6 +1476,15 @@ struct i40e_aqc_query_switching_comp_bw_config_resp {
1499 * (direct 0x041B and 0x041C) uses the generic SEID struct 1476 * (direct 0x041B and 0x041C) uses the generic SEID struct
1500 */ 1477 */
1501 1478
1479/* Configure partition BW
1480 * (indirect 0x041D)
1481 */
1482struct i40e_aqc_configure_partition_bw_data {
1483 __le16 pf_valid_bits;
1484 u8 min_bw[16]; /* guaranteed bandwidth */
1485 u8 max_bw[16]; /* bandwidth limit */
1486};
1487
1502/* Get and set the active HMC resource profile and status. 1488/* Get and set the active HMC resource profile and status.
1503 * (direct 0x0500) and (direct 0x0501) 1489 * (direct 0x0500) and (direct 0x0501)
1504 */ 1490 */
@@ -1583,11 +1569,8 @@ struct i40e_aq_get_phy_abilities_resp {
1583#define I40E_AQ_PHY_FLAG_PAUSE_TX 0x01 1569#define I40E_AQ_PHY_FLAG_PAUSE_TX 0x01
1584#define I40E_AQ_PHY_FLAG_PAUSE_RX 0x02 1570#define I40E_AQ_PHY_FLAG_PAUSE_RX 0x02
1585#define I40E_AQ_PHY_FLAG_LOW_POWER 0x04 1571#define I40E_AQ_PHY_FLAG_LOW_POWER 0x04
1586#define I40E_AQ_PHY_FLAG_AN_SHIFT 3 1572#define I40E_AQ_PHY_LINK_ENABLED 0x08
1587#define I40E_AQ_PHY_FLAG_AN_MASK (0x3 << I40E_AQ_PHY_FLAG_AN_SHIFT) 1573#define I40E_AQ_PHY_AN_ENABLED 0x10
1588#define I40E_AQ_PHY_FLAG_AN_OFF 0x00 /* link forced on */
1589#define I40E_AQ_PHY_FLAG_AN_OFF_LINK_DOWN 0x01
1590#define I40E_AQ_PHY_FLAG_AN_ON 0x02
1591#define I40E_AQ_PHY_FLAG_MODULE_QUAL 0x20 1574#define I40E_AQ_PHY_FLAG_MODULE_QUAL 0x20
1592 __le16 eee_capability; 1575 __le16 eee_capability;
1593#define I40E_AQ_EEE_100BASE_TX 0x0002 1576#define I40E_AQ_EEE_100BASE_TX 0x0002
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_lan_hmc.h b/drivers/net/ethernet/intel/i40evf/i40e_lan_hmc.h
index 17e42ca26d0b..775fcb2463d7 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_lan_hmc.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_lan_hmc.h
@@ -53,6 +53,7 @@ struct i40e_hmc_obj_rxq {
53 u8 tphdata_ena; 53 u8 tphdata_ena;
54 u8 tphhead_ena; 54 u8 tphhead_ena;
55 u8 lrxqthresh; 55 u8 lrxqthresh;
56 u8 prefena; /* NOTE: normally must be set to 1 at init */
56}; 57};
57 58
58/* Tx queue context data */ 59/* Tx queue context data */
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 2797548fde0d..da6054cbd9c0 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -31,7 +31,7 @@ char i40evf_driver_name[] = "i40evf";
31static const char i40evf_driver_string[] = 31static const char i40evf_driver_string[] =
32 "Intel(R) XL710 X710 Virtual Function Network Driver"; 32 "Intel(R) XL710 X710 Virtual Function Network Driver";
33 33
34#define DRV_VERSION "0.9.16" 34#define DRV_VERSION "0.9.21"
35const char i40evf_driver_version[] = DRV_VERSION; 35const char i40evf_driver_version[] = DRV_VERSION;
36static const char i40evf_copyright[] = 36static const char i40evf_copyright[] =
37 "Copyright (c) 2013 - 2014 Intel Corporation."; 37 "Copyright (c) 2013 - 2014 Intel Corporation.";