1 /*******************************************************************************
3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2015 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, see <http://www.gnu.org/licenses/>.
18 The full GNU General Public License is included in this distribution in
19 the file called "COPYING".
22 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *******************************************************************************/
30 /* On Hyper-V, to reset, we need to read from this offset
31 * from the PCI config space. This is the mechanism used on
32 * Hyper-V to support PF/VF communication.
34 #define IXGBE_HV_RESET_OFFSET 0x201
36 static inline s32
ixgbevf_write_msg_read_ack(struct ixgbe_hw
*hw
, u32
*msg
,
37 u32
*retmsg
, u16 size
)
39 struct ixgbe_mbx_info
*mbx
= &hw
->mbx
;
40 s32 retval
= mbx
->ops
.write_posted(hw
, msg
, size
);
45 return mbx
->ops
.read_posted(hw
, retmsg
, size
);
49 * ixgbevf_start_hw_vf - Prepare hardware for Tx/Rx
50 * @hw: pointer to hardware structure
52 * Starts the hardware by filling the bus info structure and media type, clears
53 * all on chip counters, initializes receive address registers, multicast
54 * table, VLAN filter table, calls routine to set up link and flow control
55 * settings, and leaves transmit and receive units disabled and uninitialized
57 static s32
ixgbevf_start_hw_vf(struct ixgbe_hw
*hw
)
59 /* Clear adapter stopped flag */
60 hw
->adapter_stopped
= false;
66 * ixgbevf_init_hw_vf - virtual function hardware initialization
67 * @hw: pointer to hardware structure
69 * Initialize the hardware by resetting the hardware and then starting
72 static s32
ixgbevf_init_hw_vf(struct ixgbe_hw
*hw
)
74 s32 status
= hw
->mac
.ops
.start_hw(hw
);
76 hw
->mac
.ops
.get_mac_addr(hw
, hw
->mac
.addr
);
82 * ixgbevf_reset_hw_vf - Performs hardware reset
83 * @hw: pointer to hardware structure
85 * Resets the hardware by resetting the transmit and receive units, masks and
86 * clears all interrupts.
88 static s32
ixgbevf_reset_hw_vf(struct ixgbe_hw
*hw
)
90 struct ixgbe_mbx_info
*mbx
= &hw
->mbx
;
91 u32 timeout
= IXGBE_VF_INIT_TIMEOUT
;
92 s32 ret_val
= IXGBE_ERR_INVALID_MAC_ADDR
;
93 u32 msgbuf
[IXGBE_VF_PERMADDR_MSG_LEN
];
94 u8
*addr
= (u8
*)(&msgbuf
[1]);
96 /* Call adapter stop to disable tx/rx and clear interrupts */
97 hw
->mac
.ops
.stop_adapter(hw
);
99 /* reset the api version */
100 hw
->api_version
= ixgbe_mbox_api_10
;
102 IXGBE_WRITE_REG(hw
, IXGBE_VFCTRL
, IXGBE_CTRL_RST
);
103 IXGBE_WRITE_FLUSH(hw
);
105 /* we cannot reset while the RSTI / RSTD bits are asserted */
106 while (!mbx
->ops
.check_for_rst(hw
) && timeout
) {
112 return IXGBE_ERR_RESET_FAILED
;
114 /* mailbox timeout can now become active */
115 mbx
->timeout
= IXGBE_VF_MBX_INIT_TIMEOUT
;
117 msgbuf
[0] = IXGBE_VF_RESET
;
118 mbx
->ops
.write_posted(hw
, msgbuf
, 1);
122 /* set our "perm_addr" based on info provided by PF
123 * also set up the mc_filter_type which is piggy backed
124 * on the mac address in word 3
126 ret_val
= mbx
->ops
.read_posted(hw
, msgbuf
, IXGBE_VF_PERMADDR_MSG_LEN
);
130 /* New versions of the PF may NACK the reset return message
131 * to indicate that no MAC address has yet been assigned for
134 if (msgbuf
[0] != (IXGBE_VF_RESET
| IXGBE_VT_MSGTYPE_ACK
) &&
135 msgbuf
[0] != (IXGBE_VF_RESET
| IXGBE_VT_MSGTYPE_NACK
))
136 return IXGBE_ERR_INVALID_MAC_ADDR
;
138 if (msgbuf
[0] == (IXGBE_VF_RESET
| IXGBE_VT_MSGTYPE_ACK
))
139 ether_addr_copy(hw
->mac
.perm_addr
, addr
);
141 hw
->mac
.mc_filter_type
= msgbuf
[IXGBE_VF_MC_TYPE_WORD
];
147 * Hyper-V variant; the VF/PF communication is through the PCI
149 * @hw: pointer to private hardware struct
151 static s32
ixgbevf_hv_reset_hw_vf(struct ixgbe_hw
*hw
)
153 #if IS_ENABLED(CONFIG_PCI_MMCONFIG)
154 struct ixgbevf_adapter
*adapter
= hw
->back
;
157 for (i
= 0; i
< 6; i
++)
158 pci_read_config_byte(adapter
->pdev
,
159 (i
+ IXGBE_HV_RESET_OFFSET
),
160 &hw
->mac
.perm_addr
[i
]);
163 pr_err("PCI_MMCONFIG needs to be enabled for Hyper-V\n");
169 * ixgbevf_stop_hw_vf - Generic stop Tx/Rx units
170 * @hw: pointer to hardware structure
172 * Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts,
173 * disables transmit and receive units. The adapter_stopped flag is used by
174 * the shared code and drivers to determine if the adapter is in a stopped
175 * state and should not touch the hardware.
177 static s32
ixgbevf_stop_hw_vf(struct ixgbe_hw
*hw
)
179 u32 number_of_queues
;
183 /* Set the adapter_stopped flag so other driver functions stop touching
186 hw
->adapter_stopped
= true;
188 /* Disable the receive unit by stopped each queue */
189 number_of_queues
= hw
->mac
.max_rx_queues
;
190 for (i
= 0; i
< number_of_queues
; i
++) {
191 reg_val
= IXGBE_READ_REG(hw
, IXGBE_VFRXDCTL(i
));
192 if (reg_val
& IXGBE_RXDCTL_ENABLE
) {
193 reg_val
&= ~IXGBE_RXDCTL_ENABLE
;
194 IXGBE_WRITE_REG(hw
, IXGBE_VFRXDCTL(i
), reg_val
);
198 IXGBE_WRITE_FLUSH(hw
);
200 /* Clear interrupt mask to stop from interrupts being generated */
201 IXGBE_WRITE_REG(hw
, IXGBE_VTEIMC
, IXGBE_VF_IRQ_CLEAR_MASK
);
203 /* Clear any pending interrupts */
204 IXGBE_READ_REG(hw
, IXGBE_VTEICR
);
206 /* Disable the transmit unit. Each queue must be disabled. */
207 number_of_queues
= hw
->mac
.max_tx_queues
;
208 for (i
= 0; i
< number_of_queues
; i
++) {
209 reg_val
= IXGBE_READ_REG(hw
, IXGBE_VFTXDCTL(i
));
210 if (reg_val
& IXGBE_TXDCTL_ENABLE
) {
211 reg_val
&= ~IXGBE_TXDCTL_ENABLE
;
212 IXGBE_WRITE_REG(hw
, IXGBE_VFTXDCTL(i
), reg_val
);
220 * ixgbevf_mta_vector - Determines bit-vector in multicast table to set
221 * @hw: pointer to hardware structure
222 * @mc_addr: the multicast address
224 * Extracts the 12 bits, from a multicast address, to determine which
225 * bit-vector to set in the multicast table. The hardware uses 12 bits, from
226 * incoming Rx multicast addresses, to determine the bit-vector to check in
227 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set
228 * by the MO field of the MCSTCTRL. The MO field is set during initialization
231 static s32
ixgbevf_mta_vector(struct ixgbe_hw
*hw
, u8
*mc_addr
)
235 switch (hw
->mac
.mc_filter_type
) {
236 case 0: /* use bits [47:36] of the address */
237 vector
= ((mc_addr
[4] >> 4) | (((u16
)mc_addr
[5]) << 4));
239 case 1: /* use bits [46:35] of the address */
240 vector
= ((mc_addr
[4] >> 3) | (((u16
)mc_addr
[5]) << 5));
242 case 2: /* use bits [45:34] of the address */
243 vector
= ((mc_addr
[4] >> 2) | (((u16
)mc_addr
[5]) << 6));
245 case 3: /* use bits [43:32] of the address */
246 vector
= ((mc_addr
[4]) | (((u16
)mc_addr
[5]) << 8));
248 default: /* Invalid mc_filter_type */
252 /* vector can only be 12-bits or boundary will be exceeded */
258 * ixgbevf_get_mac_addr_vf - Read device MAC address
259 * @hw: pointer to the HW structure
260 * @mac_addr: pointer to storage for retrieved MAC address
262 static s32
ixgbevf_get_mac_addr_vf(struct ixgbe_hw
*hw
, u8
*mac_addr
)
264 ether_addr_copy(mac_addr
, hw
->mac
.perm_addr
);
269 static s32
ixgbevf_set_uc_addr_vf(struct ixgbe_hw
*hw
, u32 index
, u8
*addr
)
271 u32 msgbuf
[3], msgbuf_chk
;
272 u8
*msg_addr
= (u8
*)(&msgbuf
[1]);
275 memset(msgbuf
, 0, sizeof(msgbuf
));
276 /* If index is one then this is the start of a new list and needs
277 * indication to the PF so it can do it's own list management.
278 * If it is zero then that tells the PF to just clear all of
279 * this VF's macvlans and there is no new list.
281 msgbuf
[0] |= index
<< IXGBE_VT_MSGINFO_SHIFT
;
282 msgbuf
[0] |= IXGBE_VF_SET_MACVLAN
;
283 msgbuf_chk
= msgbuf
[0];
286 ether_addr_copy(msg_addr
, addr
);
288 ret_val
= ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
,
291 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
293 if (msgbuf
[0] == (msgbuf_chk
| IXGBE_VT_MSGTYPE_NACK
))
300 static s32
ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw
*hw
, u32 index
, u8
*addr
)
306 * ixgbevf_get_reta_locked - get the RSS redirection table (RETA) contents.
307 * @hw: pointer to hardware structure
308 * @reta: buffer to fill with RETA contents.
309 * @num_rx_queues: Number of Rx queues configured for this port
311 * The "reta" buffer should be big enough to contain 32 registers.
313 * Returns: 0 on success.
314 * if API doesn't support this operation - (-EOPNOTSUPP).
316 int ixgbevf_get_reta_locked(struct ixgbe_hw
*hw
, u32
*reta
, int num_rx_queues
)
319 u32 msgbuf
[IXGBE_VFMAILBOX_SIZE
];
320 u32
*hw_reta
= &msgbuf
[1];
323 /* We have to use a mailbox for 82599 and x540 devices only.
324 * For these devices RETA has 128 entries.
325 * Also these VFs support up to 4 RSS queues. Therefore PF will compress
326 * 16 RETA entries in each DWORD giving 2 bits to each entry.
328 int dwords
= IXGBEVF_82599_RETA_SIZE
/ 16;
330 /* We support the RSS querying for 82599 and x540 devices only.
331 * Thus return an error if API doesn't support RETA querying or querying
332 * is not supported for this device type.
334 switch (hw
->api_version
) {
335 case ixgbe_mbox_api_13
:
336 case ixgbe_mbox_api_12
:
337 if (hw
->mac
.type
< ixgbe_mac_X550_vf
)
344 msgbuf
[0] = IXGBE_VF_GET_RETA
;
346 err
= hw
->mbx
.ops
.write_posted(hw
, msgbuf
, 1);
351 err
= hw
->mbx
.ops
.read_posted(hw
, msgbuf
, dwords
+ 1);
356 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
358 /* If the operation has been refused by a PF return -EPERM */
359 if (msgbuf
[0] == (IXGBE_VF_GET_RETA
| IXGBE_VT_MSGTYPE_NACK
))
362 /* If we didn't get an ACK there must have been
363 * some sort of mailbox error so we should treat it
366 if (msgbuf
[0] != (IXGBE_VF_GET_RETA
| IXGBE_VT_MSGTYPE_ACK
))
367 return IXGBE_ERR_MBX
;
369 /* ixgbevf doesn't support more than 2 queues at the moment */
370 if (num_rx_queues
> 1)
373 for (i
= 0; i
< dwords
; i
++)
374 for (j
= 0; j
< 16; j
++)
375 reta
[i
* 16 + j
] = (hw_reta
[i
] >> (2 * j
)) & mask
;
381 * ixgbevf_get_rss_key_locked - get the RSS Random Key
382 * @hw: pointer to the HW structure
383 * @rss_key: buffer to fill with RSS Hash Key contents.
385 * The "rss_key" buffer should be big enough to contain 10 registers.
387 * Returns: 0 on success.
388 * if API doesn't support this operation - (-EOPNOTSUPP).
390 int ixgbevf_get_rss_key_locked(struct ixgbe_hw
*hw
, u8
*rss_key
)
393 u32 msgbuf
[IXGBE_VFMAILBOX_SIZE
];
395 /* We currently support the RSS Random Key retrieval for 82599 and x540
398 * Thus return an error if API doesn't support RSS Random Key retrieval
399 * or if the operation is not supported for this device type.
401 switch (hw
->api_version
) {
402 case ixgbe_mbox_api_13
:
403 case ixgbe_mbox_api_12
:
404 if (hw
->mac
.type
< ixgbe_mac_X550_vf
)
411 msgbuf
[0] = IXGBE_VF_GET_RSS_KEY
;
412 err
= hw
->mbx
.ops
.write_posted(hw
, msgbuf
, 1);
417 err
= hw
->mbx
.ops
.read_posted(hw
, msgbuf
, 11);
422 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
424 /* If the operation has been refused by a PF return -EPERM */
425 if (msgbuf
[0] == (IXGBE_VF_GET_RSS_KEY
| IXGBE_VT_MSGTYPE_NACK
))
428 /* If we didn't get an ACK there must have been
429 * some sort of mailbox error so we should treat it
432 if (msgbuf
[0] != (IXGBE_VF_GET_RSS_KEY
| IXGBE_VT_MSGTYPE_ACK
))
433 return IXGBE_ERR_MBX
;
435 memcpy(rss_key
, msgbuf
+ 1, IXGBEVF_RSS_HASH_KEY_SIZE
);
441 * ixgbevf_set_rar_vf - set device MAC address
442 * @hw: pointer to hardware structure
443 * @index: Receive address register to write
444 * @addr: Address to put into receive address register
445 * @vmdq: Unused in this implementation
447 static s32
ixgbevf_set_rar_vf(struct ixgbe_hw
*hw
, u32 index
, u8
*addr
,
451 u8
*msg_addr
= (u8
*)(&msgbuf
[1]);
454 memset(msgbuf
, 0, sizeof(msgbuf
));
455 msgbuf
[0] = IXGBE_VF_SET_MAC_ADDR
;
456 ether_addr_copy(msg_addr
, addr
);
458 ret_val
= ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
,
460 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
462 /* if nacked the address was rejected, use "perm_addr" */
464 (msgbuf
[0] == (IXGBE_VF_SET_MAC_ADDR
| IXGBE_VT_MSGTYPE_NACK
))) {
465 ixgbevf_get_mac_addr_vf(hw
, hw
->mac
.addr
);
466 return IXGBE_ERR_MBX
;
473 * ixgbevf_hv_set_rar_vf - set device MAC address Hyper-V variant
474 * @hw: pointer to hardware structure
475 * @index: Receive address register to write
476 * @addr: Address to put into receive address register
477 * @vmdq: Unused in this implementation
479 * We don't really allow setting the device MAC address. However,
480 * if the address being set is the permanent MAC address we will
483 static s32
ixgbevf_hv_set_rar_vf(struct ixgbe_hw
*hw
, u32 index
, u8
*addr
,
486 if (ether_addr_equal(addr
, hw
->mac
.perm_addr
))
493 * ixgbevf_update_mc_addr_list_vf - Update Multicast addresses
494 * @hw: pointer to the HW structure
495 * @netdev: pointer to net device structure
497 * Updates the Multicast Table Array.
499 static s32
ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw
*hw
,
500 struct net_device
*netdev
)
502 struct netdev_hw_addr
*ha
;
503 u32 msgbuf
[IXGBE_VFMAILBOX_SIZE
];
504 u16
*vector_list
= (u16
*)&msgbuf
[1];
507 /* Each entry in the list uses 1 16 bit word. We have 30
508 * 16 bit words available in our HW msg buffer (minus 1 for the
509 * msg type). That's 30 hash values if we pack 'em right. If
510 * there are more than 30 MC addresses to add then punt the
511 * extras for now and then add code to handle more than 30 later.
512 * It would be unusual for a server to request that many multi-cast
513 * addresses except for in large enterprise network environments.
516 cnt
= netdev_mc_count(netdev
);
519 msgbuf
[0] = IXGBE_VF_SET_MULTICAST
;
520 msgbuf
[0] |= cnt
<< IXGBE_VT_MSGINFO_SHIFT
;
523 netdev_for_each_mc_addr(ha
, netdev
) {
526 if (is_link_local_ether_addr(ha
->addr
))
529 vector_list
[i
++] = ixgbevf_mta_vector(hw
, ha
->addr
);
532 ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
, IXGBE_VFMAILBOX_SIZE
);
538 * Hyper-V variant - just a stub.
542 static s32
ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw
*hw
,
543 struct net_device
*netdev
)
549 * ixgbevf_update_xcast_mode - Update Multicast mode
550 * @hw: pointer to the HW structure
551 * @xcast_mode: new multicast mode
553 * Updates the Multicast Mode of VF.
555 static s32
ixgbevf_update_xcast_mode(struct ixgbe_hw
*hw
, int xcast_mode
)
560 switch (hw
->api_version
) {
561 case ixgbe_mbox_api_12
:
562 /* promisc introduced in 1.3 version */
563 if (xcast_mode
== IXGBEVF_XCAST_MODE_PROMISC
)
566 case ixgbe_mbox_api_13
:
572 msgbuf
[0] = IXGBE_VF_UPDATE_XCAST_MODE
;
573 msgbuf
[1] = xcast_mode
;
575 err
= ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
,
580 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
581 if (msgbuf
[0] == (IXGBE_VF_UPDATE_XCAST_MODE
| IXGBE_VT_MSGTYPE_NACK
))
588 * Hyper-V variant - just a stub.
590 * @xcast_mode: unused
592 static s32
ixgbevf_hv_update_xcast_mode(struct ixgbe_hw
*hw
, int xcast_mode
)
598 * ixgbevf_set_vfta_vf - Set/Unset VLAN filter table address
599 * @hw: pointer to the HW structure
600 * @vlan: 12 bit VLAN ID
601 * @vind: unused by VF drivers
602 * @vlan_on: if true then set bit, else clear bit
604 static s32
ixgbevf_set_vfta_vf(struct ixgbe_hw
*hw
, u32 vlan
, u32 vind
,
610 msgbuf
[0] = IXGBE_VF_SET_VLAN
;
612 /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
613 msgbuf
[0] |= vlan_on
<< IXGBE_VT_MSGINFO_SHIFT
;
615 err
= ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
,
620 /* remove extra bits from the message */
621 msgbuf
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
622 msgbuf
[0] &= ~(0xFF << IXGBE_VT_MSGINFO_SHIFT
);
624 if (msgbuf
[0] != (IXGBE_VF_SET_VLAN
| IXGBE_VT_MSGTYPE_ACK
))
625 err
= IXGBE_ERR_INVALID_ARGUMENT
;
632 * Hyper-V variant - just a stub.
638 static s32
ixgbevf_hv_set_vfta_vf(struct ixgbe_hw
*hw
, u32 vlan
, u32 vind
,
645 * ixgbevf_setup_mac_link_vf - Setup MAC link settings
646 * @hw: pointer to hardware structure
647 * @speed: Unused in this implementation
648 * @autoneg: Unused in this implementation
649 * @autoneg_wait_to_complete: Unused in this implementation
651 * Do nothing and return success. VF drivers are not allowed to change
652 * global settings. Maintained for driver compatibility.
654 static s32
ixgbevf_setup_mac_link_vf(struct ixgbe_hw
*hw
,
655 ixgbe_link_speed speed
, bool autoneg
,
656 bool autoneg_wait_to_complete
)
662 * ixgbevf_check_mac_link_vf - Get link/speed status
663 * @hw: pointer to hardware structure
664 * @speed: pointer to link speed
665 * @link_up: true is link is up, false otherwise
666 * @autoneg_wait_to_complete: unused
668 * Reads the links register to determine if link is up and the current speed
670 static s32
ixgbevf_check_mac_link_vf(struct ixgbe_hw
*hw
,
671 ixgbe_link_speed
*speed
,
673 bool autoneg_wait_to_complete
)
675 struct ixgbe_mbx_info
*mbx
= &hw
->mbx
;
676 struct ixgbe_mac_info
*mac
= &hw
->mac
;
681 /* If we were hit with a reset drop the link */
682 if (!mbx
->ops
.check_for_rst(hw
) || !mbx
->timeout
)
683 mac
->get_link_status
= true;
685 if (!mac
->get_link_status
)
688 /* if link status is down no point in checking to see if pf is up */
689 links_reg
= IXGBE_READ_REG(hw
, IXGBE_VFLINKS
);
690 if (!(links_reg
& IXGBE_LINKS_UP
))
693 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
694 * before the link status is correct
696 if (mac
->type
== ixgbe_mac_82599_vf
) {
699 for (i
= 0; i
< 5; i
++) {
701 links_reg
= IXGBE_READ_REG(hw
, IXGBE_VFLINKS
);
703 if (!(links_reg
& IXGBE_LINKS_UP
))
708 switch (links_reg
& IXGBE_LINKS_SPEED_82599
) {
709 case IXGBE_LINKS_SPEED_10G_82599
:
710 *speed
= IXGBE_LINK_SPEED_10GB_FULL
;
712 case IXGBE_LINKS_SPEED_1G_82599
:
713 *speed
= IXGBE_LINK_SPEED_1GB_FULL
;
715 case IXGBE_LINKS_SPEED_100_82599
:
716 *speed
= IXGBE_LINK_SPEED_100_FULL
;
720 /* if the read failed it could just be a mailbox collision, best wait
721 * until we are called again and don't report an error
723 if (mbx
->ops
.read(hw
, &in_msg
, 1))
726 if (!(in_msg
& IXGBE_VT_MSGTYPE_CTS
)) {
727 /* msg is not CTS and is NACK we must have lost CTS status */
728 if (in_msg
& IXGBE_VT_MSGTYPE_NACK
)
733 /* the pf is talking, if we timed out in the past we reinit */
739 /* if we passed all the tests above then the link is up and we no
740 * longer need to check for link
742 mac
->get_link_status
= false;
745 *link_up
= !mac
->get_link_status
;
750 * Hyper-V variant; there is no mailbox communication.
751 * @hw: pointer to private hardware struct
752 * @speed: pointer to link speed
753 * @link_up: true is link is up, false otherwise
754 * @autoneg_wait_to_complete: unused
756 static s32
ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw
*hw
,
757 ixgbe_link_speed
*speed
,
759 bool autoneg_wait_to_complete
)
761 struct ixgbe_mbx_info
*mbx
= &hw
->mbx
;
762 struct ixgbe_mac_info
*mac
= &hw
->mac
;
765 /* If we were hit with a reset drop the link */
766 if (!mbx
->ops
.check_for_rst(hw
) || !mbx
->timeout
)
767 mac
->get_link_status
= true;
769 if (!mac
->get_link_status
)
772 /* if link status is down no point in checking to see if pf is up */
773 links_reg
= IXGBE_READ_REG(hw
, IXGBE_VFLINKS
);
774 if (!(links_reg
& IXGBE_LINKS_UP
))
777 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
778 * before the link status is correct
780 if (mac
->type
== ixgbe_mac_82599_vf
) {
783 for (i
= 0; i
< 5; i
++) {
785 links_reg
= IXGBE_READ_REG(hw
, IXGBE_VFLINKS
);
787 if (!(links_reg
& IXGBE_LINKS_UP
))
792 switch (links_reg
& IXGBE_LINKS_SPEED_82599
) {
793 case IXGBE_LINKS_SPEED_10G_82599
:
794 *speed
= IXGBE_LINK_SPEED_10GB_FULL
;
796 case IXGBE_LINKS_SPEED_1G_82599
:
797 *speed
= IXGBE_LINK_SPEED_1GB_FULL
;
799 case IXGBE_LINKS_SPEED_100_82599
:
800 *speed
= IXGBE_LINK_SPEED_100_FULL
;
804 /* if we passed all the tests above then the link is up and we no
805 * longer need to check for link
807 mac
->get_link_status
= false;
810 *link_up
= !mac
->get_link_status
;
815 * ixgbevf_set_rlpml_vf - Set the maximum receive packet length
816 * @hw: pointer to the HW structure
817 * @max_size: value to assign to max frame size
819 static s32
ixgbevf_set_rlpml_vf(struct ixgbe_hw
*hw
, u16 max_size
)
824 msgbuf
[0] = IXGBE_VF_SET_LPE
;
825 msgbuf
[1] = max_size
;
827 ret_val
= ixgbevf_write_msg_read_ack(hw
, msgbuf
, msgbuf
,
831 if ((msgbuf
[0] & IXGBE_VF_SET_LPE
) &&
832 (msgbuf
[0] & IXGBE_VT_MSGTYPE_NACK
))
833 return IXGBE_ERR_MBX
;
839 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
840 * @hw: pointer to the HW structure
841 * @max_size: value to assign to max frame size
844 static s32
ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw
*hw
, u16 max_size
)
848 /* If we are on Hyper-V, we implement this functionality
851 reg
= IXGBE_READ_REG(hw
, IXGBE_VFRXDCTL(0));
853 reg
|= ((max_size
+ 4) | IXGBE_RXDCTL_RLPML_EN
);
854 IXGBE_WRITE_REG(hw
, IXGBE_VFRXDCTL(0), reg
);
860 * ixgbevf_negotiate_api_version_vf - Negotiate supported API version
861 * @hw: pointer to the HW structure
862 * @api: integer containing requested API version
864 static int ixgbevf_negotiate_api_version_vf(struct ixgbe_hw
*hw
, int api
)
869 /* Negotiate the mailbox API version */
870 msg
[0] = IXGBE_VF_API_NEGOTIATE
;
874 err
= ixgbevf_write_msg_read_ack(hw
, msg
, msg
, ARRAY_SIZE(msg
));
876 msg
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
878 /* Store value and return 0 on success */
879 if (msg
[0] == (IXGBE_VF_API_NEGOTIATE
| IXGBE_VT_MSGTYPE_ACK
)) {
880 hw
->api_version
= api
;
884 err
= IXGBE_ERR_INVALID_ARGUMENT
;
891 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
892 * @hw: pointer to the HW structure
893 * @api: integer containing requested API version
894 * Hyper-V version - only ixgbe_mbox_api_10 supported.
896 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw
*hw
, int api
)
898 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
899 if (api
!= ixgbe_mbox_api_10
)
900 return IXGBE_ERR_INVALID_ARGUMENT
;
905 int ixgbevf_get_queues(struct ixgbe_hw
*hw
, unsigned int *num_tcs
,
906 unsigned int *default_tc
)
911 /* do nothing if API doesn't support ixgbevf_get_queues */
912 switch (hw
->api_version
) {
913 case ixgbe_mbox_api_11
:
914 case ixgbe_mbox_api_12
:
915 case ixgbe_mbox_api_13
:
921 /* Fetch queue configuration from the PF */
922 msg
[0] = IXGBE_VF_GET_QUEUE
;
923 msg
[1] = msg
[2] = msg
[3] = msg
[4] = 0;
925 err
= ixgbevf_write_msg_read_ack(hw
, msg
, msg
, ARRAY_SIZE(msg
));
927 msg
[0] &= ~IXGBE_VT_MSGTYPE_CTS
;
929 /* if we we didn't get an ACK there must have been
930 * some sort of mailbox error so we should treat it
933 if (msg
[0] != (IXGBE_VF_GET_QUEUE
| IXGBE_VT_MSGTYPE_ACK
))
934 return IXGBE_ERR_MBX
;
936 /* record and validate values from message */
937 hw
->mac
.max_tx_queues
= msg
[IXGBE_VF_TX_QUEUES
];
938 if (hw
->mac
.max_tx_queues
== 0 ||
939 hw
->mac
.max_tx_queues
> IXGBE_VF_MAX_TX_QUEUES
)
940 hw
->mac
.max_tx_queues
= IXGBE_VF_MAX_TX_QUEUES
;
942 hw
->mac
.max_rx_queues
= msg
[IXGBE_VF_RX_QUEUES
];
943 if (hw
->mac
.max_rx_queues
== 0 ||
944 hw
->mac
.max_rx_queues
> IXGBE_VF_MAX_RX_QUEUES
)
945 hw
->mac
.max_rx_queues
= IXGBE_VF_MAX_RX_QUEUES
;
947 *num_tcs
= msg
[IXGBE_VF_TRANS_VLAN
];
948 /* in case of unknown state assume we cannot tag frames */
949 if (*num_tcs
> hw
->mac
.max_rx_queues
)
952 *default_tc
= msg
[IXGBE_VF_DEF_QUEUE
];
953 /* default to queue 0 on out-of-bounds queue number */
954 if (*default_tc
>= hw
->mac
.max_tx_queues
)
961 static const struct ixgbe_mac_operations ixgbevf_mac_ops
= {
962 .init_hw
= ixgbevf_init_hw_vf
,
963 .reset_hw
= ixgbevf_reset_hw_vf
,
964 .start_hw
= ixgbevf_start_hw_vf
,
965 .get_mac_addr
= ixgbevf_get_mac_addr_vf
,
966 .stop_adapter
= ixgbevf_stop_hw_vf
,
967 .setup_link
= ixgbevf_setup_mac_link_vf
,
968 .check_link
= ixgbevf_check_mac_link_vf
,
969 .negotiate_api_version
= ixgbevf_negotiate_api_version_vf
,
970 .set_rar
= ixgbevf_set_rar_vf
,
971 .update_mc_addr_list
= ixgbevf_update_mc_addr_list_vf
,
972 .update_xcast_mode
= ixgbevf_update_xcast_mode
,
973 .set_uc_addr
= ixgbevf_set_uc_addr_vf
,
974 .set_vfta
= ixgbevf_set_vfta_vf
,
975 .set_rlpml
= ixgbevf_set_rlpml_vf
,
978 static const struct ixgbe_mac_operations ixgbevf_hv_mac_ops
= {
979 .init_hw
= ixgbevf_init_hw_vf
,
980 .reset_hw
= ixgbevf_hv_reset_hw_vf
,
981 .start_hw
= ixgbevf_start_hw_vf
,
982 .get_mac_addr
= ixgbevf_get_mac_addr_vf
,
983 .stop_adapter
= ixgbevf_stop_hw_vf
,
984 .setup_link
= ixgbevf_setup_mac_link_vf
,
985 .check_link
= ixgbevf_hv_check_mac_link_vf
,
986 .negotiate_api_version
= ixgbevf_hv_negotiate_api_version_vf
,
987 .set_rar
= ixgbevf_hv_set_rar_vf
,
988 .update_mc_addr_list
= ixgbevf_hv_update_mc_addr_list_vf
,
989 .update_xcast_mode
= ixgbevf_hv_update_xcast_mode
,
990 .set_uc_addr
= ixgbevf_hv_set_uc_addr_vf
,
991 .set_vfta
= ixgbevf_hv_set_vfta_vf
,
992 .set_rlpml
= ixgbevf_hv_set_rlpml_vf
,
995 const struct ixgbevf_info ixgbevf_82599_vf_info
= {
996 .mac
= ixgbe_mac_82599_vf
,
997 .mac_ops
= &ixgbevf_mac_ops
,
1000 const struct ixgbevf_info ixgbevf_82599_vf_hv_info
= {
1001 .mac
= ixgbe_mac_82599_vf
,
1002 .mac_ops
= &ixgbevf_hv_mac_ops
,
1005 const struct ixgbevf_info ixgbevf_X540_vf_info
= {
1006 .mac
= ixgbe_mac_X540_vf
,
1007 .mac_ops
= &ixgbevf_mac_ops
,
1010 const struct ixgbevf_info ixgbevf_X540_vf_hv_info
= {
1011 .mac
= ixgbe_mac_X540_vf
,
1012 .mac_ops
= &ixgbevf_hv_mac_ops
,
1015 const struct ixgbevf_info ixgbevf_X550_vf_info
= {
1016 .mac
= ixgbe_mac_X550_vf
,
1017 .mac_ops
= &ixgbevf_mac_ops
,
1020 const struct ixgbevf_info ixgbevf_X550_vf_hv_info
= {
1021 .mac
= ixgbe_mac_X550_vf
,
1022 .mac_ops
= &ixgbevf_hv_mac_ops
,
1025 const struct ixgbevf_info ixgbevf_X550EM_x_vf_info
= {
1026 .mac
= ixgbe_mac_X550EM_x_vf
,
1027 .mac_ops
= &ixgbevf_mac_ops
,
1030 const struct ixgbevf_info ixgbevf_X550EM_x_vf_hv_info
= {
1031 .mac
= ixgbe_mac_X550EM_x_vf
,
1032 .mac_ops
= &ixgbevf_hv_mac_ops
,
1035 const struct ixgbevf_info ixgbevf_x550em_a_vf_info
= {
1036 .mac
= ixgbe_mac_x550em_a_vf
,
1037 .mac_ops
= &ixgbevf_mac_ops
,