bnx2x_vfpf.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* bnx2x_vfpf.c: Broadcom Everest network driver.
  2. *
  3. * Copyright 2009-2012 Broadcom Corporation
  4. *
  5. * Unless you and Broadcom execute a separate written software license
  6. * agreement governing use of this software, this software is licensed to you
  7. * under the terms of the GNU General Public License version 2, available
  8. * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
  9. *
  10. * Notwithstanding the above, under no circumstances may you combine this
  11. * software in any way with any other Broadcom software provided under a
  12. * license other than the GPL, without Broadcom's express prior written
  13. * consent.
  14. *
  15. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  16. * Written by: Shmulik Ravid <shmulikr@broadcom.com>
  17. * Ariel Elior <ariele@broadcom.com>
  18. */
  19. #include "bnx2x.h"
  20. #include "bnx2x_sriov.h"
  21. /* place a given tlv on the tlv buffer at a given offset */
  22. void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
  23. u16 length)
  24. {
  25. struct channel_tlv *tl =
  26. (struct channel_tlv *)(tlvs_list + offset);
  27. tl->type = type;
  28. tl->length = length;
  29. }
  30. /* Clear the mailbox and init the header of the first tlv */
  31. void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
  32. u16 type, u16 length)
  33. {
  34. DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n",
  35. type);
  36. /* Clear mailbox */
  37. memset(bp->vf2pf_mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
  38. /* init type and length */
  39. bnx2x_add_tlv(bp, &first_tlv->tl, 0, type, length);
  40. /* init first tlv header */
  41. first_tlv->resp_msg_offset = sizeof(bp->vf2pf_mbox->req);
  42. }
  43. /* list the types and lengths of the tlvs on the buffer */
  44. void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list)
  45. {
  46. int i = 1;
  47. struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
  48. while (tlv->type != CHANNEL_TLV_LIST_END) {
  49. /* output tlv */
  50. DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
  51. tlv->type, tlv->length);
  52. /* advance to next tlv */
  53. tlvs_list += tlv->length;
  54. /* cast general tlv list pointer to channel tlv header*/
  55. tlv = (struct channel_tlv *)tlvs_list;
  56. i++;
  57. /* break condition for this loop */
  58. if (i > MAX_TLVS_IN_LIST) {
  59. WARN(true, "corrupt tlvs");
  60. return;
  61. }
  62. }
  63. /* output last tlv */
  64. DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
  65. tlv->type, tlv->length);
  66. }