Print this page
6064 ixgbe needs X550 support

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ixgbe/ixgbe_mbx.c
          +++ new/usr/src/uts/common/io/ixgbe/ixgbe_mbx.c
   1    1  /******************************************************************************
   2    2  
   3      -  Copyright (c) 2001-2012, Intel Corporation 
        3 +  Copyright (c) 2001-2015, Intel Corporation 
   4    4    All rights reserved.
   5    5    
   6    6    Redistribution and use in source and binary forms, with or without 
   7    7    modification, are permitted provided that the following conditions are met:
   8    8    
   9    9     1. Redistributions of source code must retain the above copyright notice, 
  10   10        this list of conditions and the following disclaimer.
  11   11    
  12   12     2. Redistributions in binary form must reproduce the above copyright 
  13   13        notice, this list of conditions and the following disclaimer in the 
↓ open down ↓ 56 lines elided ↑ open up ↑
  70   70   *
  71   71   *  returns SUCCESS if it successfully copied message into the buffer
  72   72   **/
  73   73  s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
  74   74  {
  75   75          struct ixgbe_mbx_info *mbx = &hw->mbx;
  76   76          s32 ret_val = IXGBE_SUCCESS;
  77   77  
  78   78          DEBUGFUNC("ixgbe_write_mbx");
  79   79  
  80      -        if (size > mbx->size)
       80 +        if (size > mbx->size) {
  81   81                  ret_val = IXGBE_ERR_MBX;
  82      -
  83      -        else if (mbx->ops.write)
       82 +                ERROR_REPORT2(IXGBE_ERROR_ARGUMENT,
       83 +                             "Invalid mailbox message size %d", size);
       84 +        } else if (mbx->ops.write)
  84   85                  ret_val = mbx->ops.write(hw, msg, size, mbx_id);
  85   86  
  86   87          return ret_val;
  87   88  }
  88   89  
  89   90  /**
  90   91   *  ixgbe_check_for_msg - checks to see if someone sent us mail
  91   92   *  @hw: pointer to the HW structure
  92   93   *  @mbx_id: id of mailbox to check
  93   94   *
↓ open down ↓ 69 lines elided ↑ open up ↑
 163  164          if (!countdown || !mbx->ops.check_for_msg)
 164  165                  goto out;
 165  166  
 166  167          while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
 167  168                  countdown--;
 168  169                  if (!countdown)
 169  170                          break;
 170  171                  usec_delay(mbx->usec_delay);
 171  172          }
 172  173  
      174 +        if (countdown == 0)
      175 +                ERROR_REPORT2(IXGBE_ERROR_POLLING,
      176 +                           "Polling for VF%d mailbox message timedout", mbx_id);
      177 +
 173  178  out:
 174  179          return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 175  180  }
 176  181  
 177  182  /**
 178  183   *  ixgbe_poll_for_ack - Wait for message acknowledgement
 179  184   *  @hw: pointer to the HW structure
 180  185   *  @mbx_id: id of mailbox to write
 181  186   *
 182  187   *  returns SUCCESS if it successfully received a message acknowledgement
↓ open down ↓ 8 lines elided ↑ open up ↑
 191  196          if (!countdown || !mbx->ops.check_for_ack)
 192  197                  goto out;
 193  198  
 194  199          while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
 195  200                  countdown--;
 196  201                  if (!countdown)
 197  202                          break;
 198  203                  usec_delay(mbx->usec_delay);
 199  204          }
 200  205  
      206 +        if (countdown == 0)
      207 +                ERROR_REPORT2(IXGBE_ERROR_POLLING,
      208 +                             "Polling for VF%d mailbox ack timedout", mbx_id);
      209 +
 201  210  out:
 202  211          return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 203  212  }
 204  213  
 205  214  /**
 206  215   *  ixgbe_read_posted_mbx - Wait for message notification and receive message
 207  216   *  @hw: pointer to the HW structure
 208  217   *  @msg: The message buffer
 209  218   *  @size: Length of buffer
 210  219   *  @mbx_id: id of mailbox to write
↓ open down ↓ 211 lines elided ↑ open up ↑
 422  431          UNREFERENCED_1PARAMETER(mbx_id);
 423  432  
 424  433          DEBUGFUNC("ixgbe_write_mbx_vf");
 425  434  
 426  435          /* lock the mailbox to prevent pf/vf race condition */
 427  436          ret_val = ixgbe_obtain_mbx_lock_vf(hw);
 428  437          if (ret_val)
 429  438                  goto out_no_write;
 430  439  
 431  440          /* flush msg and acks as we are overwriting the message buffer */
 432      -        ret_val = ixgbe_check_for_msg_vf(hw, 0);
 433      -        if (ret_val)
 434      -                goto out_no_write;
 435      -        ret_val = ixgbe_check_for_ack_vf(hw, 0);
 436      -        if (ret_val)
 437      -                goto out_no_write;
      441 +        ixgbe_check_for_msg_vf(hw, 0);
      442 +        ixgbe_check_for_ack_vf(hw, 0);
 438  443  
 439  444          /* copy the caller specified message to the mailbox memory buffer */
 440  445          for (i = 0; i < size; i++)
 441  446                  IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);
 442  447  
 443  448          /* update stats */
 444  449          hw->mbx.stats.msgs_tx++;
 445  450  
 446  451          /* Drop VFU and interrupt the PF to tell it a message has been sent */
 447  452          IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ);
↓ open down ↓ 145 lines elided ↑ open up ↑
 593  598          u32 vf_shift = vf_number % 32;
 594  599          u32 vflre = 0;
 595  600          s32 ret_val = IXGBE_ERR_MBX;
 596  601  
 597  602          DEBUGFUNC("ixgbe_check_for_rst_pf");
 598  603  
 599  604          switch (hw->mac.type) {
 600  605          case ixgbe_mac_82599EB:
 601  606                  vflre = IXGBE_READ_REG(hw, IXGBE_VFLRE(reg_offset));
 602  607                  break;
      608 +        case ixgbe_mac_X550:
      609 +        case ixgbe_mac_X550EM_x:
 603  610          case ixgbe_mac_X540:
 604  611                  vflre = IXGBE_READ_REG(hw, IXGBE_VFLREC(reg_offset));
 605  612                  break;
 606  613          default:
 607  614                  break;
 608  615          }
 609  616  
 610  617          if (vflre & (1 << vf_shift)) {
 611  618                  ret_val = IXGBE_SUCCESS;
 612  619                  IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift));
↓ open down ↓ 17 lines elided ↑ open up ↑
 630  637  
 631  638          DEBUGFUNC("ixgbe_obtain_mbx_lock_pf");
 632  639  
 633  640          /* Take ownership of the buffer */
 634  641          IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_PFU);
 635  642  
 636  643          /* reserve mailbox for vf use */
 637  644          p2v_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_number));
 638  645          if (p2v_mailbox & IXGBE_PFMAILBOX_PFU)
 639  646                  ret_val = IXGBE_SUCCESS;
      647 +        else
      648 +                ERROR_REPORT2(IXGBE_ERROR_POLLING,
      649 +                           "Failed to obtain mailbox lock for VF%d", vf_number);
 640  650  
      651 +
 641  652          return ret_val;
 642  653  }
 643  654  
 644  655  /**
 645  656   *  ixgbe_write_mbx_pf - Places a message in the mailbox
 646  657   *  @hw: pointer to the HW structure
 647  658   *  @msg: The message buffer
 648  659   *  @size: Length of buffer
 649  660   *  @vf_number: the VF index
 650  661   *
↓ open down ↓ 6 lines elided ↑ open up ↑
 657  668          u16 i;
 658  669  
 659  670          DEBUGFUNC("ixgbe_write_mbx_pf");
 660  671  
 661  672          /* lock the mailbox to prevent pf/vf race condition */
 662  673          ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number);
 663  674          if (ret_val)
 664  675                  goto out_no_write;
 665  676  
 666  677          /* flush msg and acks as we are overwriting the message buffer */
 667      -        ret_val = ixgbe_check_for_msg_vf(hw, 0);
 668      -        if (ret_val)
 669      -                goto out_no_write;
 670      -        ret_val = ixgbe_check_for_ack_vf(hw, 0);
 671      -        if (ret_val)
 672      -                goto out_no_write;
      678 +        ixgbe_check_for_msg_pf(hw, vf_number);
      679 +        ixgbe_check_for_ack_pf(hw, vf_number);
 673  680  
 674  681          /* copy the caller specified message to the mailbox memory buffer */
 675  682          for (i = 0; i < size; i++)
 676  683                  IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_number), i, msg[i]);
 677  684  
 678  685          /* Interrupt VF to tell it a message has been sent and release buffer*/
 679  686          IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_STS);
 680  687  
 681  688          /* update stats */
 682  689          hw->mbx.stats.msgs_tx++;
↓ open down ↓ 45 lines elided ↑ open up ↑
 728  735   *  ixgbe_init_mbx_params_pf - set initial values for pf mailbox
 729  736   *  @hw: pointer to the HW structure
 730  737   *
 731  738   *  Initializes the hw->mbx struct to correct values for pf mailbox
 732  739   */
 733  740  void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw)
 734  741  {
 735  742          struct ixgbe_mbx_info *mbx = &hw->mbx;
 736  743  
 737  744          if (hw->mac.type != ixgbe_mac_82599EB &&
      745 +            hw->mac.type != ixgbe_mac_X550 &&
      746 +            hw->mac.type != ixgbe_mac_X550EM_x &&
 738  747              hw->mac.type != ixgbe_mac_X540)
 739  748                  return;
 740  749  
 741  750          mbx->timeout = 0;
 742  751          mbx->usec_delay = 0;
 743  752  
 744  753          mbx->size = IXGBE_VFMAILBOX_SIZE;
 745  754  
 746  755          mbx->ops.read = ixgbe_read_mbx_pf;
 747  756          mbx->ops.write = ixgbe_write_mbx_pf;
↓ open down ↓ 12 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX