Lines Matching +full:hw +full:- +full:device +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2024 Intel Corporation. */
7 /* On Hyper-V, to reset, we need to read from this offset
9 * Hyper-V to support PF/VF communication.
13 static inline s32 ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw, u32 *msg, in ixgbevf_write_msg_read_ack() argument
16 s32 retval = ixgbevf_write_mbx(hw, msg, size); in ixgbevf_write_msg_read_ack()
21 return ixgbevf_poll_mbx(hw, retmsg, size); in ixgbevf_write_msg_read_ack()
25 * ixgbevf_start_hw_vf - Prepare hardware for Tx/Rx
26 * @hw: pointer to hardware structure
29 * all on chip counters, initializes receive address registers, multicast
33 static s32 ixgbevf_start_hw_vf(struct ixgbe_hw *hw) in ixgbevf_start_hw_vf() argument
36 hw->adapter_stopped = false; in ixgbevf_start_hw_vf()
42 * ixgbevf_init_hw_vf - virtual function hardware initialization
43 * @hw: pointer to hardware structure
48 static s32 ixgbevf_init_hw_vf(struct ixgbe_hw *hw) in ixgbevf_init_hw_vf() argument
50 s32 status = hw->mac.ops.start_hw(hw); in ixgbevf_init_hw_vf()
52 hw->mac.ops.get_mac_addr(hw, hw->mac.addr); in ixgbevf_init_hw_vf()
58 * ixgbevf_reset_hw_vf - Performs hardware reset
59 * @hw: pointer to hardware structure
64 static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw) in ixgbevf_reset_hw_vf() argument
66 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbevf_reset_hw_vf()
73 hw->mac.ops.stop_adapter(hw); in ixgbevf_reset_hw_vf()
76 hw->api_version = ixgbe_mbox_api_10; in ixgbevf_reset_hw_vf()
77 hw->mbx.ops.init_params(hw); in ixgbevf_reset_hw_vf()
78 memcpy(&hw->mbx.ops, &ixgbevf_mbx_ops_legacy, in ixgbevf_reset_hw_vf()
81 IXGBE_WRITE_REG(hw, IXGBE_VFCTRL, IXGBE_CTRL_RST); in ixgbevf_reset_hw_vf()
82 IXGBE_WRITE_FLUSH(hw); in ixgbevf_reset_hw_vf()
85 while (!mbx->ops.check_for_rst(hw) && timeout) { in ixgbevf_reset_hw_vf()
86 timeout--; in ixgbevf_reset_hw_vf()
94 mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT; in ixgbevf_reset_hw_vf()
97 ixgbevf_write_mbx(hw, msgbuf, 1); in ixgbevf_reset_hw_vf()
103 * on the mac address in word 3 in ixgbevf_reset_hw_vf()
105 ret_val = ixgbevf_poll_mbx(hw, msgbuf, IXGBE_VF_PERMADDR_MSG_LEN); in ixgbevf_reset_hw_vf()
110 * to indicate that no MAC address has yet been assigned for in ixgbevf_reset_hw_vf()
118 ether_addr_copy(hw->mac.perm_addr, addr); in ixgbevf_reset_hw_vf()
120 hw->mac.mc_filter_type = msgbuf[IXGBE_VF_MC_TYPE_WORD]; in ixgbevf_reset_hw_vf()
126 * ixgbevf_hv_reset_hw_vf - reset via Hyper-V
127 * @hw: pointer to private hardware struct
129 * Hyper-V variant; the VF/PF communication is through the PCI
132 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw) in ixgbevf_hv_reset_hw_vf() argument
135 struct ixgbevf_adapter *adapter = hw->back; in ixgbevf_hv_reset_hw_vf()
139 pci_read_config_byte(adapter->pdev, in ixgbevf_hv_reset_hw_vf()
141 &hw->mac.perm_addr[i]); in ixgbevf_hv_reset_hw_vf()
144 pr_err("PCI_MMCONFIG needs to be enabled for Hyper-V\n"); in ixgbevf_hv_reset_hw_vf()
145 return -EOPNOTSUPP; in ixgbevf_hv_reset_hw_vf()
150 * ixgbevf_stop_hw_vf - Generic stop Tx/Rx units
151 * @hw: pointer to hardware structure
158 static s32 ixgbevf_stop_hw_vf(struct ixgbe_hw *hw) in ixgbevf_stop_hw_vf() argument
167 hw->adapter_stopped = true; in ixgbevf_stop_hw_vf()
170 number_of_queues = hw->mac.max_rx_queues; in ixgbevf_stop_hw_vf()
172 reg_val = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)); in ixgbevf_stop_hw_vf()
175 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), reg_val); in ixgbevf_stop_hw_vf()
179 IXGBE_WRITE_FLUSH(hw); in ixgbevf_stop_hw_vf()
182 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK); in ixgbevf_stop_hw_vf()
185 IXGBE_READ_REG(hw, IXGBE_VTEICR); in ixgbevf_stop_hw_vf()
188 number_of_queues = hw->mac.max_tx_queues; in ixgbevf_stop_hw_vf()
190 reg_val = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i)); in ixgbevf_stop_hw_vf()
193 IXGBE_WRITE_REG(hw, IXGBE_VFTXDCTL(i), reg_val); in ixgbevf_stop_hw_vf()
201 * ixgbevf_mta_vector - Determines bit-vector in multicast table to set
202 * @hw: pointer to hardware structure
203 * @mc_addr: the multicast address
205 * Extracts the 12 bits, from a multicast address, to determine which
206 * bit-vector to set in the multicast table. The hardware uses 12 bits, from
207 * incoming Rx multicast addresses, to determine the bit-vector to check in
208 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set
212 static s32 ixgbevf_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr) in ixgbevf_mta_vector() argument
216 switch (hw->mac.mc_filter_type) { in ixgbevf_mta_vector()
217 case 0: /* use bits [47:36] of the address */ in ixgbevf_mta_vector()
220 case 1: /* use bits [46:35] of the address */ in ixgbevf_mta_vector()
223 case 2: /* use bits [45:34] of the address */ in ixgbevf_mta_vector()
226 case 3: /* use bits [43:32] of the address */ in ixgbevf_mta_vector()
233 /* vector can only be 12-bits or boundary will be exceeded */ in ixgbevf_mta_vector()
239 * ixgbevf_get_mac_addr_vf - Read device MAC address
240 * @hw: pointer to the HW structure
241 * @mac_addr: pointer to storage for retrieved MAC address
243 static s32 ixgbevf_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr) in ixgbevf_get_mac_addr_vf() argument
245 ether_addr_copy(mac_addr, hw->mac.perm_addr); in ixgbevf_get_mac_addr_vf()
250 static s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr) in ixgbevf_set_uc_addr_vf() argument
269 ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_set_uc_addr_vf()
275 return -ENOMEM; in ixgbevf_set_uc_addr_vf()
281 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr) in ixgbevf_hv_set_uc_addr_vf() argument
283 return -EOPNOTSUPP; in ixgbevf_hv_set_uc_addr_vf()
287 * ixgbevf_get_reta_locked - get the RSS redirection table (RETA) contents.
288 * @hw: pointer to hardware structure
295 * if API doesn't support this operation - (-EOPNOTSUPP).
297 int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues) in ixgbevf_get_reta_locked() argument
313 * is not supported for this device type. in ixgbevf_get_reta_locked()
315 switch (hw->api_version) { in ixgbevf_get_reta_locked()
320 if (hw->mac.type < ixgbe_mac_X550_vf) in ixgbevf_get_reta_locked()
324 return -EOPNOTSUPP; in ixgbevf_get_reta_locked()
329 err = ixgbevf_write_mbx(hw, msgbuf, 1); in ixgbevf_get_reta_locked()
334 err = ixgbevf_poll_mbx(hw, msgbuf, dwords + 1); in ixgbevf_get_reta_locked()
341 /* If the operation has been refused by a PF return -EPERM */ in ixgbevf_get_reta_locked()
343 return -EPERM; in ixgbevf_get_reta_locked()
364 * ixgbevf_get_rss_key_locked - get the RSS Random Key
365 * @hw: pointer to the HW structure
371 * if API doesn't support this operation - (-EOPNOTSUPP).
373 int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key) in ixgbevf_get_rss_key_locked() argument
382 * or if the operation is not supported for this device type. in ixgbevf_get_rss_key_locked()
384 switch (hw->api_version) { in ixgbevf_get_rss_key_locked()
389 if (hw->mac.type < ixgbe_mac_X550_vf) in ixgbevf_get_rss_key_locked()
393 return -EOPNOTSUPP; in ixgbevf_get_rss_key_locked()
397 err = ixgbevf_write_mbx(hw, msgbuf, 1); in ixgbevf_get_rss_key_locked()
402 err = ixgbevf_poll_mbx(hw, msgbuf, 11); in ixgbevf_get_rss_key_locked()
409 /* If the operation has been refused by a PF return -EPERM */ in ixgbevf_get_rss_key_locked()
411 return -EPERM; in ixgbevf_get_rss_key_locked()
426 * ixgbevf_set_rar_vf - set device MAC address
427 * @hw: pointer to hardware structure
428 * @index: Receive address register to write
429 * @addr: Address to put into receive address register
432 static s32 ixgbevf_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, in ixgbevf_set_rar_vf() argument
443 ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_set_rar_vf()
447 /* if nacked the address was rejected, use "perm_addr" */ in ixgbevf_set_rar_vf()
450 ixgbevf_get_mac_addr_vf(hw, hw->mac.addr); in ixgbevf_set_rar_vf()
458 * ixgbevf_hv_set_rar_vf - set device MAC address Hyper-V variant
459 * @hw: pointer to hardware structure
460 * @index: Receive address register to write
461 * @addr: Address to put into receive address register
464 * We don't really allow setting the device MAC address. However,
465 * if the address being set is the permanent MAC address we will
468 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, in ixgbevf_hv_set_rar_vf() argument
471 if (ether_addr_equal(addr, hw->mac.perm_addr)) in ixgbevf_hv_set_rar_vf()
474 return -EOPNOTSUPP; in ixgbevf_hv_set_rar_vf()
478 * ixgbevf_update_mc_addr_list_vf - Update Multicast addresses
479 * @hw: pointer to the HW structure
480 * @netdev: pointer to net device structure
484 static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw, in ixgbevf_update_mc_addr_list_vf() argument
493 * 16 bit words available in our HW msg buffer (minus 1 for the in ixgbevf_update_mc_addr_list_vf()
497 * It would be unusual for a server to request that many multi-cast in ixgbevf_update_mc_addr_list_vf()
511 if (is_link_local_ether_addr(ha->addr)) in ixgbevf_update_mc_addr_list_vf()
514 vector_list[i++] = ixgbevf_mta_vector(hw, ha->addr); in ixgbevf_update_mc_addr_list_vf()
517 return ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_update_mc_addr_list_vf()
522 * ixgbevf_hv_update_mc_addr_list_vf - stub
523 * @hw: unused
526 * Hyper-V variant - just a stub.
528 static s32 ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw *hw, in ixgbevf_hv_update_mc_addr_list_vf() argument
531 return -EOPNOTSUPP; in ixgbevf_hv_update_mc_addr_list_vf()
535 * ixgbevf_update_xcast_mode - Update Multicast mode
536 * @hw: pointer to the HW structure
541 static s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode) in ixgbevf_update_xcast_mode() argument
546 switch (hw->api_version) { in ixgbevf_update_xcast_mode()
550 return -EOPNOTSUPP; in ixgbevf_update_xcast_mode()
557 return -EOPNOTSUPP; in ixgbevf_update_xcast_mode()
563 err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_update_xcast_mode()
570 return -EPERM; in ixgbevf_update_xcast_mode()
576 * ixgbevf_hv_update_xcast_mode - stub
577 * @hw: unused
580 * Hyper-V variant - just a stub.
582 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode) in ixgbevf_hv_update_xcast_mode() argument
584 return -EOPNOTSUPP; in ixgbevf_hv_update_xcast_mode()
588 * ixgbevf_get_link_state_vf - Get VF link state from PF
589 * @hw: pointer to the HW structure
594 static s32 ixgbevf_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state) in ixgbevf_get_link_state_vf() argument
603 err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2); in ixgbevf_get_link_state_vf()
616 * ixgbevf_hv_get_link_state_vf - * Hyper-V variant - just a stub.
617 * @hw: unused
620 * Hyper-V variant; there is no mailbox communication.
622 static s32 ixgbevf_hv_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state) in ixgbevf_hv_get_link_state_vf() argument
624 return -EOPNOTSUPP; in ixgbevf_hv_get_link_state_vf()
628 * ixgbevf_set_vfta_vf - Set/Unset VLAN filter table address
629 * @hw: pointer to the HW structure
634 static s32 ixgbevf_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind, in ixgbevf_set_vfta_vf() argument
645 err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_set_vfta_vf()
662 * ixgbevf_hv_set_vfta_vf - * Hyper-V variant - just a stub.
663 * @hw: unused
668 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind, in ixgbevf_hv_set_vfta_vf() argument
671 return -EOPNOTSUPP; in ixgbevf_hv_set_vfta_vf()
675 * ixgbevf_setup_mac_link_vf - Setup MAC link settings
676 * @hw: pointer to hardware structure
684 static s32 ixgbevf_setup_mac_link_vf(struct ixgbe_hw *hw, in ixgbevf_setup_mac_link_vf() argument
692 * ixgbevf_check_mac_link_vf - Get link/speed status
693 * @hw: pointer to hardware structure
700 static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw, in ixgbevf_check_mac_link_vf() argument
705 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbevf_check_mac_link_vf()
706 struct ixgbe_mac_info *mac = &hw->mac; in ixgbevf_check_mac_link_vf()
712 if (!mbx->ops.check_for_rst(hw) || !mbx->timeout) in ixgbevf_check_mac_link_vf()
713 mac->get_link_status = true; in ixgbevf_check_mac_link_vf()
715 if (!mac->get_link_status) in ixgbevf_check_mac_link_vf()
719 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); in ixgbevf_check_mac_link_vf()
726 if (mac->type == ixgbe_mac_82599_vf) { in ixgbevf_check_mac_link_vf()
731 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); in ixgbevf_check_mac_link_vf()
753 if (mbx->ops.read(hw, &in_msg, 1)) { in ixgbevf_check_mac_link_vf()
754 if (hw->api_version >= ixgbe_mbox_api_15) in ixgbevf_check_mac_link_vf()
755 mac->get_link_status = false; in ixgbevf_check_mac_link_vf()
762 ret_val = -1; in ixgbevf_check_mac_link_vf()
767 if (!mbx->timeout) { in ixgbevf_check_mac_link_vf()
768 ret_val = -1; in ixgbevf_check_mac_link_vf()
775 mac->get_link_status = false; in ixgbevf_check_mac_link_vf()
778 *link_up = !mac->get_link_status; in ixgbevf_check_mac_link_vf()
783 * ixgbevf_hv_check_mac_link_vf - check link
784 * @hw: pointer to private hardware struct
789 * Hyper-V variant; there is no mailbox communication.
791 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw, in ixgbevf_hv_check_mac_link_vf() argument
796 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbevf_hv_check_mac_link_vf()
797 struct ixgbe_mac_info *mac = &hw->mac; in ixgbevf_hv_check_mac_link_vf()
801 if (!mbx->ops.check_for_rst(hw) || !mbx->timeout) in ixgbevf_hv_check_mac_link_vf()
802 mac->get_link_status = true; in ixgbevf_hv_check_mac_link_vf()
804 if (!mac->get_link_status) in ixgbevf_hv_check_mac_link_vf()
808 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); in ixgbevf_hv_check_mac_link_vf()
815 if (mac->type == ixgbe_mac_82599_vf) { in ixgbevf_hv_check_mac_link_vf()
820 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); in ixgbevf_hv_check_mac_link_vf()
842 mac->get_link_status = false; in ixgbevf_hv_check_mac_link_vf()
845 *link_up = !mac->get_link_status; in ixgbevf_hv_check_mac_link_vf()
850 * ixgbevf_set_rlpml_vf - Set the maximum receive packet length
851 * @hw: pointer to the HW structure
854 static s32 ixgbevf_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size) in ixgbevf_set_rlpml_vf() argument
862 ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, in ixgbevf_set_rlpml_vf()
874 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
875 * @hw: pointer to the HW structure
877 * Hyper-V variant.
879 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size) in ixgbevf_hv_set_rlpml_vf() argument
883 /* If we are on Hyper-V, we implement this functionality in ixgbevf_hv_set_rlpml_vf()
886 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0)); in ixgbevf_hv_set_rlpml_vf()
889 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg); in ixgbevf_hv_set_rlpml_vf()
895 * ixgbevf_negotiate_api_version_vf - Negotiate supported API version
896 * @hw: pointer to the HW structure
899 static int ixgbevf_negotiate_api_version_vf(struct ixgbe_hw *hw, int api) in ixgbevf_negotiate_api_version_vf() argument
909 err = ixgbevf_write_msg_read_ack(hw, msg, msg, ARRAY_SIZE(msg)); in ixgbevf_negotiate_api_version_vf()
916 hw->api_version = api; in ixgbevf_negotiate_api_version_vf()
927 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
928 * @hw: pointer to the HW structure
930 * Hyper-V version - only ixgbe_mbox_api_10 supported.
932 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api) in ixgbevf_hv_negotiate_api_version_vf() argument
934 /* Hyper-V only supports api version ixgbe_mbox_api_10 */ in ixgbevf_hv_negotiate_api_version_vf()
941 int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs, in ixgbevf_get_queues() argument
948 switch (hw->api_version) { in ixgbevf_get_queues()
963 err = ixgbevf_write_msg_read_ack(hw, msg, msg, ARRAY_SIZE(msg)); in ixgbevf_get_queues()
975 hw->mac.max_tx_queues = msg[IXGBE_VF_TX_QUEUES]; in ixgbevf_get_queues()
976 if (hw->mac.max_tx_queues == 0 || in ixgbevf_get_queues()
977 hw->mac.max_tx_queues > IXGBE_VF_MAX_TX_QUEUES) in ixgbevf_get_queues()
978 hw->mac.max_tx_queues = IXGBE_VF_MAX_TX_QUEUES; in ixgbevf_get_queues()
980 hw->mac.max_rx_queues = msg[IXGBE_VF_RX_QUEUES]; in ixgbevf_get_queues()
981 if (hw->mac.max_rx_queues == 0 || in ixgbevf_get_queues()
982 hw->mac.max_rx_queues > IXGBE_VF_MAX_RX_QUEUES) in ixgbevf_get_queues()
983 hw->mac.max_rx_queues = IXGBE_VF_MAX_RX_QUEUES; in ixgbevf_get_queues()
987 if (*num_tcs > hw->mac.max_rx_queues) in ixgbevf_get_queues()
991 /* default to queue 0 on out-of-bounds queue number */ in ixgbevf_get_queues()
992 if (*default_tc >= hw->mac.max_tx_queues) in ixgbevf_get_queues()