Print this page
6064 ixgbe needs X550 support
   1 /******************************************************************************
   2 
   3   Copyright (c) 2001-2012, 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   
  12    2. Redistributions in binary form must reproduce the above copyright 
  13       notice, this list of conditions and the following disclaimer in the 
  14       documentation and/or other materials provided with the distribution.
  15   
  16    3. Neither the name of the Intel Corporation nor the names of its 
  17       contributors may be used to endorse or promote products derived from 
  18       this software without specific prior written permission.
  19   
  20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 


  60 
  61         return ret_val;
  62 }
  63 
  64 /**
  65  *  ixgbe_write_mbx - Write a message to the mailbox
  66  *  @hw: pointer to the HW structure
  67  *  @msg: The message buffer
  68  *  @size: Length of buffer
  69  *  @mbx_id: id of mailbox to write
  70  *
  71  *  returns SUCCESS if it successfully copied message into the buffer
  72  **/
  73 s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
  74 {
  75         struct ixgbe_mbx_info *mbx = &hw->mbx;
  76         s32 ret_val = IXGBE_SUCCESS;
  77 
  78         DEBUGFUNC("ixgbe_write_mbx");
  79 
  80         if (size > mbx->size)
  81                 ret_val = IXGBE_ERR_MBX;
  82 
  83         else if (mbx->ops.write)

  84                 ret_val = mbx->ops.write(hw, msg, size, mbx_id);
  85 
  86         return ret_val;
  87 }
  88 
  89 /**
  90  *  ixgbe_check_for_msg - checks to see if someone sent us mail
  91  *  @hw: pointer to the HW structure
  92  *  @mbx_id: id of mailbox to check
  93  *
  94  *  returns SUCCESS if the Status bit was found or else ERR_MBX
  95  **/
  96 s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
  97 {
  98         struct ixgbe_mbx_info *mbx = &hw->mbx;
  99         s32 ret_val = IXGBE_ERR_MBX;
 100 
 101         DEBUGFUNC("ixgbe_check_for_msg");
 102 
 103         if (mbx->ops.check_for_msg)


 153  *
 154  *  returns SUCCESS if it successfully received a message notification
 155  **/
 156 static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
 157 {
 158         struct ixgbe_mbx_info *mbx = &hw->mbx;
 159         int countdown = mbx->timeout;
 160 
 161         DEBUGFUNC("ixgbe_poll_for_msg");
 162 
 163         if (!countdown || !mbx->ops.check_for_msg)
 164                 goto out;
 165 
 166         while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
 167                 countdown--;
 168                 if (!countdown)
 169                         break;
 170                 usec_delay(mbx->usec_delay);
 171         }
 172 




 173 out:
 174         return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 175 }
 176 
 177 /**
 178  *  ixgbe_poll_for_ack - Wait for message acknowledgement
 179  *  @hw: pointer to the HW structure
 180  *  @mbx_id: id of mailbox to write
 181  *
 182  *  returns SUCCESS if it successfully received a message acknowledgement
 183  **/
 184 static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
 185 {
 186         struct ixgbe_mbx_info *mbx = &hw->mbx;
 187         int countdown = mbx->timeout;
 188 
 189         DEBUGFUNC("ixgbe_poll_for_ack");
 190 
 191         if (!countdown || !mbx->ops.check_for_ack)
 192                 goto out;
 193 
 194         while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
 195                 countdown--;
 196                 if (!countdown)
 197                         break;
 198                 usec_delay(mbx->usec_delay);
 199         }
 200 




 201 out:
 202         return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 203 }
 204 
 205 /**
 206  *  ixgbe_read_posted_mbx - Wait for message notification and receive message
 207  *  @hw: pointer to the HW structure
 208  *  @msg: The message buffer
 209  *  @size: Length of buffer
 210  *  @mbx_id: id of mailbox to write
 211  *
 212  *  returns SUCCESS if it successfully received a message notification and
 213  *  copied it into the receive buffer.
 214  **/
 215 s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 216 {
 217         struct ixgbe_mbx_info *mbx = &hw->mbx;
 218         s32 ret_val = IXGBE_ERR_MBX;
 219 
 220         DEBUGFUNC("ixgbe_read_posted_mbx");


 412  *  @mbx_id: id of mailbox to write
 413  *
 414  *  returns SUCCESS if it successfully copied message into the buffer
 415  **/
 416 static s32 ixgbe_write_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 417                               u16 mbx_id)
 418 {
 419         s32 ret_val;
 420         u16 i;
 421 
 422         UNREFERENCED_1PARAMETER(mbx_id);
 423 
 424         DEBUGFUNC("ixgbe_write_mbx_vf");
 425 
 426         /* lock the mailbox to prevent pf/vf race condition */
 427         ret_val = ixgbe_obtain_mbx_lock_vf(hw);
 428         if (ret_val)
 429                 goto out_no_write;
 430 
 431         /* 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;
 438 
 439         /* copy the caller specified message to the mailbox memory buffer */
 440         for (i = 0; i < size; i++)
 441                 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);
 442 
 443         /* update stats */
 444         hw->mbx.stats.msgs_tx++;
 445 
 446         /* Drop VFU and interrupt the PF to tell it a message has been sent */
 447         IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ);
 448 
 449 out_no_write:
 450         return ret_val;
 451 }
 452 
 453 /**
 454  *  ixgbe_read_mbx_vf - Reads a message from the inbox intended for vf
 455  *  @hw: pointer to the HW structure
 456  *  @msg: The message buffer
 457  *  @size: Length of buffer


 583 /**
 584  *  ixgbe_check_for_rst_pf - checks to see if the VF has reset
 585  *  @hw: pointer to the HW structure
 586  *  @vf_number: the VF index
 587  *
 588  *  returns SUCCESS if the VF has set the Status bit or else ERR_MBX
 589  **/
 590 static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
 591 {
 592         u32 reg_offset = (vf_number < 32) ? 0 : 1;
 593         u32 vf_shift = vf_number % 32;
 594         u32 vflre = 0;
 595         s32 ret_val = IXGBE_ERR_MBX;
 596 
 597         DEBUGFUNC("ixgbe_check_for_rst_pf");
 598 
 599         switch (hw->mac.type) {
 600         case ixgbe_mac_82599EB:
 601                 vflre = IXGBE_READ_REG(hw, IXGBE_VFLRE(reg_offset));
 602                 break;


 603         case ixgbe_mac_X540:
 604                 vflre = IXGBE_READ_REG(hw, IXGBE_VFLREC(reg_offset));
 605                 break;
 606         default:
 607                 break;
 608         }
 609 
 610         if (vflre & (1 << vf_shift)) {
 611                 ret_val = IXGBE_SUCCESS;
 612                 IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift));
 613                 hw->mbx.stats.rsts++;
 614         }
 615 
 616         return ret_val;
 617 }
 618 
 619 /**
 620  *  ixgbe_obtain_mbx_lock_pf - obtain mailbox lock
 621  *  @hw: pointer to the HW structure
 622  *  @vf_number: the VF index
 623  *
 624  *  return SUCCESS if we obtained the mailbox lock
 625  **/
 626 static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number)
 627 {
 628         s32 ret_val = IXGBE_ERR_MBX;
 629         u32 p2v_mailbox;
 630 
 631         DEBUGFUNC("ixgbe_obtain_mbx_lock_pf");
 632 
 633         /* Take ownership of the buffer */
 634         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_PFU);
 635 
 636         /* reserve mailbox for vf use */
 637         p2v_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_number));
 638         if (p2v_mailbox & IXGBE_PFMAILBOX_PFU)
 639                 ret_val = IXGBE_SUCCESS;



 640 

 641         return ret_val;
 642 }
 643 
 644 /**
 645  *  ixgbe_write_mbx_pf - Places a message in the mailbox
 646  *  @hw: pointer to the HW structure
 647  *  @msg: The message buffer
 648  *  @size: Length of buffer
 649  *  @vf_number: the VF index
 650  *
 651  *  returns SUCCESS if it successfully copied message into the buffer
 652  **/
 653 static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 654                               u16 vf_number)
 655 {
 656         s32 ret_val;
 657         u16 i;
 658 
 659         DEBUGFUNC("ixgbe_write_mbx_pf");
 660 
 661         /* lock the mailbox to prevent pf/vf race condition */
 662         ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number);
 663         if (ret_val)
 664                 goto out_no_write;
 665 
 666         /* 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;
 673 
 674         /* copy the caller specified message to the mailbox memory buffer */
 675         for (i = 0; i < size; i++)
 676                 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_number), i, msg[i]);
 677 
 678         /* Interrupt VF to tell it a message has been sent and release buffer*/
 679         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_STS);
 680 
 681         /* update stats */
 682         hw->mbx.stats.msgs_tx++;
 683 
 684 out_no_write:
 685         return ret_val;
 686 
 687 }
 688 
 689 /**
 690  *  ixgbe_read_mbx_pf - Read a message from the mailbox
 691  *  @hw: pointer to the HW structure
 692  *  @msg: The message buffer


 718         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_ACK);
 719 
 720         /* update stats */
 721         hw->mbx.stats.msgs_rx++;
 722 
 723 out_no_read:
 724         return ret_val;
 725 }
 726 
 727 /**
 728  *  ixgbe_init_mbx_params_pf - set initial values for pf mailbox
 729  *  @hw: pointer to the HW structure
 730  *
 731  *  Initializes the hw->mbx struct to correct values for pf mailbox
 732  */
 733 void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw)
 734 {
 735         struct ixgbe_mbx_info *mbx = &hw->mbx;
 736 
 737         if (hw->mac.type != ixgbe_mac_82599EB &&


 738             hw->mac.type != ixgbe_mac_X540)
 739                 return;
 740 
 741         mbx->timeout = 0;
 742         mbx->usec_delay = 0;
 743 
 744         mbx->size = IXGBE_VFMAILBOX_SIZE;
 745 
 746         mbx->ops.read = ixgbe_read_mbx_pf;
 747         mbx->ops.write = ixgbe_write_mbx_pf;
 748         mbx->ops.read_posted = ixgbe_read_posted_mbx;
 749         mbx->ops.write_posted = ixgbe_write_posted_mbx;
 750         mbx->ops.check_for_msg = ixgbe_check_for_msg_pf;
 751         mbx->ops.check_for_ack = ixgbe_check_for_ack_pf;
 752         mbx->ops.check_for_rst = ixgbe_check_for_rst_pf;
 753 
 754         mbx->stats.msgs_tx = 0;
 755         mbx->stats.msgs_rx = 0;
 756         mbx->stats.reqs = 0;
 757         mbx->stats.acks = 0;
   1 /******************************************************************************
   2 
   3   Copyright (c) 2001-2015, 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   
  12    2. Redistributions in binary form must reproduce the above copyright 
  13       notice, this list of conditions and the following disclaimer in the 
  14       documentation and/or other materials provided with the distribution.
  15   
  16    3. Neither the name of the Intel Corporation nor the names of its 
  17       contributors may be used to endorse or promote products derived from 
  18       this software without specific prior written permission.
  19   
  20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 


  60 
  61         return ret_val;
  62 }
  63 
  64 /**
  65  *  ixgbe_write_mbx - Write a message to the mailbox
  66  *  @hw: pointer to the HW structure
  67  *  @msg: The message buffer
  68  *  @size: Length of buffer
  69  *  @mbx_id: id of mailbox to write
  70  *
  71  *  returns SUCCESS if it successfully copied message into the buffer
  72  **/
  73 s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
  74 {
  75         struct ixgbe_mbx_info *mbx = &hw->mbx;
  76         s32 ret_val = IXGBE_SUCCESS;
  77 
  78         DEBUGFUNC("ixgbe_write_mbx");
  79 
  80         if (size > mbx->size) {
  81                 ret_val = IXGBE_ERR_MBX;
  82                 ERROR_REPORT2(IXGBE_ERROR_ARGUMENT,
  83                              "Invalid mailbox message size %d", size);
  84         } else if (mbx->ops.write)
  85                 ret_val = mbx->ops.write(hw, msg, size, mbx_id);
  86 
  87         return ret_val;
  88 }
  89 
  90 /**
  91  *  ixgbe_check_for_msg - checks to see if someone sent us mail
  92  *  @hw: pointer to the HW structure
  93  *  @mbx_id: id of mailbox to check
  94  *
  95  *  returns SUCCESS if the Status bit was found or else ERR_MBX
  96  **/
  97 s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
  98 {
  99         struct ixgbe_mbx_info *mbx = &hw->mbx;
 100         s32 ret_val = IXGBE_ERR_MBX;
 101 
 102         DEBUGFUNC("ixgbe_check_for_msg");
 103 
 104         if (mbx->ops.check_for_msg)


 154  *
 155  *  returns SUCCESS if it successfully received a message notification
 156  **/
 157 static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
 158 {
 159         struct ixgbe_mbx_info *mbx = &hw->mbx;
 160         int countdown = mbx->timeout;
 161 
 162         DEBUGFUNC("ixgbe_poll_for_msg");
 163 
 164         if (!countdown || !mbx->ops.check_for_msg)
 165                 goto out;
 166 
 167         while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
 168                 countdown--;
 169                 if (!countdown)
 170                         break;
 171                 usec_delay(mbx->usec_delay);
 172         }
 173 
 174         if (countdown == 0)
 175                 ERROR_REPORT2(IXGBE_ERROR_POLLING,
 176                            "Polling for VF%d mailbox message timedout", mbx_id);
 177 
 178 out:
 179         return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 180 }
 181 
 182 /**
 183  *  ixgbe_poll_for_ack - Wait for message acknowledgement
 184  *  @hw: pointer to the HW structure
 185  *  @mbx_id: id of mailbox to write
 186  *
 187  *  returns SUCCESS if it successfully received a message acknowledgement
 188  **/
 189 static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
 190 {
 191         struct ixgbe_mbx_info *mbx = &hw->mbx;
 192         int countdown = mbx->timeout;
 193 
 194         DEBUGFUNC("ixgbe_poll_for_ack");
 195 
 196         if (!countdown || !mbx->ops.check_for_ack)
 197                 goto out;
 198 
 199         while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
 200                 countdown--;
 201                 if (!countdown)
 202                         break;
 203                 usec_delay(mbx->usec_delay);
 204         }
 205 
 206         if (countdown == 0)
 207                 ERROR_REPORT2(IXGBE_ERROR_POLLING,
 208                              "Polling for VF%d mailbox ack timedout", mbx_id);
 209 
 210 out:
 211         return countdown ? IXGBE_SUCCESS : IXGBE_ERR_MBX;
 212 }
 213 
 214 /**
 215  *  ixgbe_read_posted_mbx - Wait for message notification and receive message
 216  *  @hw: pointer to the HW structure
 217  *  @msg: The message buffer
 218  *  @size: Length of buffer
 219  *  @mbx_id: id of mailbox to write
 220  *
 221  *  returns SUCCESS if it successfully received a message notification and
 222  *  copied it into the receive buffer.
 223  **/
 224 s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 225 {
 226         struct ixgbe_mbx_info *mbx = &hw->mbx;
 227         s32 ret_val = IXGBE_ERR_MBX;
 228 
 229         DEBUGFUNC("ixgbe_read_posted_mbx");


 421  *  @mbx_id: id of mailbox to write
 422  *
 423  *  returns SUCCESS if it successfully copied message into the buffer
 424  **/
 425 static s32 ixgbe_write_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 426                               u16 mbx_id)
 427 {
 428         s32 ret_val;
 429         u16 i;
 430 
 431         UNREFERENCED_1PARAMETER(mbx_id);
 432 
 433         DEBUGFUNC("ixgbe_write_mbx_vf");
 434 
 435         /* lock the mailbox to prevent pf/vf race condition */
 436         ret_val = ixgbe_obtain_mbx_lock_vf(hw);
 437         if (ret_val)
 438                 goto out_no_write;
 439 
 440         /* flush msg and acks as we are overwriting the message buffer */
 441         ixgbe_check_for_msg_vf(hw, 0);
 442         ixgbe_check_for_ack_vf(hw, 0);




 443 
 444         /* copy the caller specified message to the mailbox memory buffer */
 445         for (i = 0; i < size; i++)
 446                 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);
 447 
 448         /* update stats */
 449         hw->mbx.stats.msgs_tx++;
 450 
 451         /* Drop VFU and interrupt the PF to tell it a message has been sent */
 452         IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ);
 453 
 454 out_no_write:
 455         return ret_val;
 456 }
 457 
 458 /**
 459  *  ixgbe_read_mbx_vf - Reads a message from the inbox intended for vf
 460  *  @hw: pointer to the HW structure
 461  *  @msg: The message buffer
 462  *  @size: Length of buffer


 588 /**
 589  *  ixgbe_check_for_rst_pf - checks to see if the VF has reset
 590  *  @hw: pointer to the HW structure
 591  *  @vf_number: the VF index
 592  *
 593  *  returns SUCCESS if the VF has set the Status bit or else ERR_MBX
 594  **/
 595 static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
 596 {
 597         u32 reg_offset = (vf_number < 32) ? 0 : 1;
 598         u32 vf_shift = vf_number % 32;
 599         u32 vflre = 0;
 600         s32 ret_val = IXGBE_ERR_MBX;
 601 
 602         DEBUGFUNC("ixgbe_check_for_rst_pf");
 603 
 604         switch (hw->mac.type) {
 605         case ixgbe_mac_82599EB:
 606                 vflre = IXGBE_READ_REG(hw, IXGBE_VFLRE(reg_offset));
 607                 break;
 608         case ixgbe_mac_X550:
 609         case ixgbe_mac_X550EM_x:
 610         case ixgbe_mac_X540:
 611                 vflre = IXGBE_READ_REG(hw, IXGBE_VFLREC(reg_offset));
 612                 break;
 613         default:
 614                 break;
 615         }
 616 
 617         if (vflre & (1 << vf_shift)) {
 618                 ret_val = IXGBE_SUCCESS;
 619                 IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift));
 620                 hw->mbx.stats.rsts++;
 621         }
 622 
 623         return ret_val;
 624 }
 625 
 626 /**
 627  *  ixgbe_obtain_mbx_lock_pf - obtain mailbox lock
 628  *  @hw: pointer to the HW structure
 629  *  @vf_number: the VF index
 630  *
 631  *  return SUCCESS if we obtained the mailbox lock
 632  **/
 633 static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_number)
 634 {
 635         s32 ret_val = IXGBE_ERR_MBX;
 636         u32 p2v_mailbox;
 637 
 638         DEBUGFUNC("ixgbe_obtain_mbx_lock_pf");
 639 
 640         /* Take ownership of the buffer */
 641         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_PFU);
 642 
 643         /* reserve mailbox for vf use */
 644         p2v_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_number));
 645         if (p2v_mailbox & IXGBE_PFMAILBOX_PFU)
 646                 ret_val = IXGBE_SUCCESS;
 647         else
 648                 ERROR_REPORT2(IXGBE_ERROR_POLLING,
 649                            "Failed to obtain mailbox lock for VF%d", vf_number);
 650 
 651 
 652         return ret_val;
 653 }
 654 
 655 /**
 656  *  ixgbe_write_mbx_pf - Places a message in the mailbox
 657  *  @hw: pointer to the HW structure
 658  *  @msg: The message buffer
 659  *  @size: Length of buffer
 660  *  @vf_number: the VF index
 661  *
 662  *  returns SUCCESS if it successfully copied message into the buffer
 663  **/
 664 static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 665                               u16 vf_number)
 666 {
 667         s32 ret_val;
 668         u16 i;
 669 
 670         DEBUGFUNC("ixgbe_write_mbx_pf");
 671 
 672         /* lock the mailbox to prevent pf/vf race condition */
 673         ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_number);
 674         if (ret_val)
 675                 goto out_no_write;
 676 
 677         /* flush msg and acks as we are overwriting the message buffer */
 678         ixgbe_check_for_msg_pf(hw, vf_number);
 679         ixgbe_check_for_ack_pf(hw, vf_number);




 680 
 681         /* copy the caller specified message to the mailbox memory buffer */
 682         for (i = 0; i < size; i++)
 683                 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_number), i, msg[i]);
 684 
 685         /* Interrupt VF to tell it a message has been sent and release buffer*/
 686         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_STS);
 687 
 688         /* update stats */
 689         hw->mbx.stats.msgs_tx++;
 690 
 691 out_no_write:
 692         return ret_val;
 693 
 694 }
 695 
 696 /**
 697  *  ixgbe_read_mbx_pf - Read a message from the mailbox
 698  *  @hw: pointer to the HW structure
 699  *  @msg: The message buffer


 725         IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_ACK);
 726 
 727         /* update stats */
 728         hw->mbx.stats.msgs_rx++;
 729 
 730 out_no_read:
 731         return ret_val;
 732 }
 733 
 734 /**
 735  *  ixgbe_init_mbx_params_pf - set initial values for pf mailbox
 736  *  @hw: pointer to the HW structure
 737  *
 738  *  Initializes the hw->mbx struct to correct values for pf mailbox
 739  */
 740 void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw)
 741 {
 742         struct ixgbe_mbx_info *mbx = &hw->mbx;
 743 
 744         if (hw->mac.type != ixgbe_mac_82599EB &&
 745             hw->mac.type != ixgbe_mac_X550 &&
 746             hw->mac.type != ixgbe_mac_X550EM_x &&
 747             hw->mac.type != ixgbe_mac_X540)
 748                 return;
 749 
 750         mbx->timeout = 0;
 751         mbx->usec_delay = 0;
 752 
 753         mbx->size = IXGBE_VFMAILBOX_SIZE;
 754 
 755         mbx->ops.read = ixgbe_read_mbx_pf;
 756         mbx->ops.write = ixgbe_write_mbx_pf;
 757         mbx->ops.read_posted = ixgbe_read_posted_mbx;
 758         mbx->ops.write_posted = ixgbe_write_posted_mbx;
 759         mbx->ops.check_for_msg = ixgbe_check_for_msg_pf;
 760         mbx->ops.check_for_ack = ixgbe_check_for_ack_pf;
 761         mbx->ops.check_for_rst = ixgbe_check_for_rst_pf;
 762 
 763         mbx->stats.msgs_tx = 0;
 764         mbx->stats.msgs_rx = 0;
 765         mbx->stats.reqs = 0;
 766         mbx->stats.acks = 0;