Deleted Added
full compact
ixgbe_vf.c (238149) ixgbe_vf.c (247822)
1/******************************************************************************
2
1/******************************************************************************
2
3 Copyright (c) 2001-2012, Intel Corporation
3 Copyright (c) 2001-2013, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_vf.c 238149 2012-07-05 20:51:44Z jfv $*/
33/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_vf.c 247822 2013-03-04 23:07:40Z jfv $*/
34
35
36#include "ixgbe_api.h"
37#include "ixgbe_type.h"
38#include "ixgbe_vf.h"
39
40#ifndef IXGBE_VFWRITE_REG
41#define IXGBE_VFWRITE_REG IXGBE_WRITE_REG

--- 95 unchanged lines hidden (view full) ---

137 u32 ctrl, msgbuf[IXGBE_VF_PERMADDR_MSG_LEN];
138 u8 *addr = (u8 *)(&msgbuf[1]);
139
140 DEBUGFUNC("ixgbevf_reset_hw_vf");
141
142 /* Call adapter stop to disable tx/rx and clear interrupts */
143 hw->mac.ops.stop_adapter(hw);
144
34
35
36#include "ixgbe_api.h"
37#include "ixgbe_type.h"
38#include "ixgbe_vf.h"
39
40#ifndef IXGBE_VFWRITE_REG
41#define IXGBE_VFWRITE_REG IXGBE_WRITE_REG

--- 95 unchanged lines hidden (view full) ---

137 u32 ctrl, msgbuf[IXGBE_VF_PERMADDR_MSG_LEN];
138 u8 *addr = (u8 *)(&msgbuf[1]);
139
140 DEBUGFUNC("ixgbevf_reset_hw_vf");
141
142 /* Call adapter stop to disable tx/rx and clear interrupts */
143 hw->mac.ops.stop_adapter(hw);
144
145
145 DEBUGOUT("Issuing a function level reset to MAC\n");
146
147 ctrl = IXGBE_VFREAD_REG(hw, IXGBE_VFCTRL) | IXGBE_CTRL_RST;
148 IXGBE_VFWRITE_REG(hw, IXGBE_VFCTRL, ctrl);
149 IXGBE_WRITE_FLUSH(hw);
150
151 msec_delay(50);
152

--- 114 unchanged lines hidden (view full) ---

267 break;
268 }
269
270 /* vector can only be 12-bits or boundary will be exceeded */
271 vector &= 0xFFF;
272 return vector;
273}
274
146 DEBUGOUT("Issuing a function level reset to MAC\n");
147
148 ctrl = IXGBE_VFREAD_REG(hw, IXGBE_VFCTRL) | IXGBE_CTRL_RST;
149 IXGBE_VFWRITE_REG(hw, IXGBE_VFCTRL, ctrl);
150 IXGBE_WRITE_FLUSH(hw);
151
152 msec_delay(50);
153

--- 114 unchanged lines hidden (view full) ---

268 break;
269 }
270
271 /* vector can only be 12-bits or boundary will be exceeded */
272 vector &= 0xFFF;
273 return vector;
274}
275
276static void ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw,
277 u32 *msg, u16 size)
278{
279 struct ixgbe_mbx_info *mbx = &hw->mbx;
280 u32 retmsg[IXGBE_VFMAILBOX_SIZE];
281 s32 retval = mbx->ops.write_posted(hw, msg, size, 0);
282
283 if (!retval)
284 mbx->ops.read_posted(hw, retmsg, size, 0);
285}
286
275/**
276 * ixgbe_set_rar_vf - set device MAC address
277 * @hw: pointer to hardware structure
278 * @index: Receive address register to write
279 * @addr: Address to put into receive address register
280 * @vmdq: VMDq "set" or "pool" index
281 * @enable_addr: set flag that address is active
282 **/

--- 175 unchanged lines hidden (view full) ---

458 * ixgbe_setup_mac_link_vf - Setup MAC link settings
459 * @hw: pointer to hardware structure
460 * @speed: new link speed
461 * @autoneg: TRUE if autonegotiation enabled
462 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
463 *
464 * Set the link speed in the AUTOC register and restarts link.
465 **/
287/**
288 * ixgbe_set_rar_vf - set device MAC address
289 * @hw: pointer to hardware structure
290 * @index: Receive address register to write
291 * @addr: Address to put into receive address register
292 * @vmdq: VMDq "set" or "pool" index
293 * @enable_addr: set flag that address is active
294 **/

--- 175 unchanged lines hidden (view full) ---

470 * ixgbe_setup_mac_link_vf - Setup MAC link settings
471 * @hw: pointer to hardware structure
472 * @speed: new link speed
473 * @autoneg: TRUE if autonegotiation enabled
474 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
475 *
476 * Set the link speed in the AUTOC register and restarts link.
477 **/
466s32 ixgbe_setup_mac_link_vf(struct ixgbe_hw *hw,
467 ixgbe_link_speed speed, bool autoneg,
478s32 ixgbe_setup_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed speed,
468 bool autoneg_wait_to_complete)
469{
479 bool autoneg_wait_to_complete)
480{
470 UNREFERENCED_4PARAMETER(hw, speed, autoneg, autoneg_wait_to_complete);
481 UNREFERENCED_3PARAMETER(hw, speed, autoneg_wait_to_complete);
471 return IXGBE_SUCCESS;
472}
473
474/**
475 * ixgbe_check_mac_link_vf - Get link/speed status
476 * @hw: pointer to hardware structure
477 * @speed: pointer to link speed
478 * @link_up: TRUE is link is up, FALSE otherwise
479 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
480 *
481 * Reads the links register to determine if link is up and the current speed
482 **/
483s32 ixgbe_check_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
484 bool *link_up, bool autoneg_wait_to_complete)
485{
482 return IXGBE_SUCCESS;
483}
484
485/**
486 * ixgbe_check_mac_link_vf - Get link/speed status
487 * @hw: pointer to hardware structure
488 * @speed: pointer to link speed
489 * @link_up: TRUE is link is up, FALSE otherwise
490 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
491 *
492 * Reads the links register to determine if link is up and the current speed
493 **/
494s32 ixgbe_check_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
495 bool *link_up, bool autoneg_wait_to_complete)
496{
497 struct ixgbe_mbx_info *mbx = &hw->mbx;
498 struct ixgbe_mac_info *mac = &hw->mac;
499 s32 ret_val = IXGBE_SUCCESS;
486 u32 links_reg;
500 u32 links_reg;
501 u32 in_msg = 0;
487 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
488
502 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
503
489 if (!(hw->mbx.ops.check_for_rst(hw, 0))) {
490 *link_up = FALSE;
491 *speed = 0;
492 return -1;
493 }
504 /* If we were hit with a reset drop the link */
505 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
506 mac->get_link_status = TRUE;
494
507
495 links_reg = IXGBE_VFREAD_REG(hw, IXGBE_VFLINKS);
508 if (!mac->get_link_status)
509 goto out;
496
510
497 if (links_reg & IXGBE_LINKS_UP)
498 *link_up = TRUE;
499 else
500 *link_up = FALSE;
511 /* if link status is down no point in checking to see if pf is up */
512 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
513 if (!(links_reg & IXGBE_LINKS_UP))
514 goto out;
501
515
502 switch (links_reg & IXGBE_LINKS_SPEED_10G_82599) {
516 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
503 case IXGBE_LINKS_SPEED_10G_82599:
504 *speed = IXGBE_LINK_SPEED_10GB_FULL;
505 break;
506 case IXGBE_LINKS_SPEED_1G_82599:
507 *speed = IXGBE_LINK_SPEED_1GB_FULL;
508 break;
509 case IXGBE_LINKS_SPEED_100_82599:
510 *speed = IXGBE_LINK_SPEED_100_FULL;
511 break;
512 }
513
517 case IXGBE_LINKS_SPEED_10G_82599:
518 *speed = IXGBE_LINK_SPEED_10GB_FULL;
519 break;
520 case IXGBE_LINKS_SPEED_1G_82599:
521 *speed = IXGBE_LINK_SPEED_1GB_FULL;
522 break;
523 case IXGBE_LINKS_SPEED_100_82599:
524 *speed = IXGBE_LINK_SPEED_100_FULL;
525 break;
526 }
527
528 /* if the read failed it could just be a mailbox collision, best wait
529 * until we are called again and don't report an error
530 */
531 if (mbx->ops.read(hw, &in_msg, 1, 0))
532 goto out;
533
534 if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
535 /* msg is not CTS and is NACK we must have lost CTS status */
536 if (in_msg & IXGBE_VT_MSGTYPE_NACK)
537 ret_val = -1;
538 goto out;
539 }
540
541 /* the pf is talking, if we timed out in the past we reinit */
542 if (!mbx->timeout) {
543 ret_val = -1;
544 goto out;
545 }
546
547 /* if we passed all the tests above then the link is up and we no
548 * longer need to check for link
549 */
550 mac->get_link_status = FALSE;
551
552out:
553 *link_up = !mac->get_link_status;
554 return ret_val;
555}
556
557/**
558 * ixgbevf_rlpml_set_vf - Set the maximum receive packet length
559 * @hw: pointer to the HW structure
560 * @max_size: value to assign to max frame size
561 **/
562void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size)
563{
564 u32 msgbuf[2];
565
566 msgbuf[0] = IXGBE_VF_SET_LPE;
567 msgbuf[1] = max_size;
568 ixgbevf_write_msg_read_ack(hw, msgbuf, 2);
569}
570
571/**
572 * ixgbevf_negotiate_api_version - Negotiate supported API version
573 * @hw: pointer to the HW structure
574 * @api: integer containing requested API version
575 **/
576int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api)
577{
578 int err;
579 u32 msg[3];
580
581 /* Negotiate the mailbox API version */
582 msg[0] = IXGBE_VF_API_NEGOTIATE;
583 msg[1] = api;
584 msg[2] = 0;
585 err = hw->mbx.ops.write_posted(hw, msg, 3, 0);
586
587 if (!err)
588 err = hw->mbx.ops.read_posted(hw, msg, 3, 0);
589
590 if (!err) {
591 msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;
592
593 /* Store value and return 0 on success */
594 if (msg[0] == (IXGBE_VF_API_NEGOTIATE | IXGBE_VT_MSGTYPE_ACK)) {
595 hw->api_version = api;
596 return 0;
597 }
598
599 err = IXGBE_ERR_INVALID_ARGUMENT;
600 }
601
602 return err;
603}
604
605int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
606 unsigned int *default_tc)
607{
608 UNREFERENCED_3PARAMETER(hw, num_tcs, default_tc);
514 return IXGBE_SUCCESS;
515}
516
609 return IXGBE_SUCCESS;
610}
611