Ariel Elior | be1f1ffa | 2013-01-01 05:22:24 +0000 | [diff] [blame^] | 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 | |
| 20 | #include "bnx2x.h" |
| 21 | #include "bnx2x_sriov.h" |
| 22 | |
| 23 | /* place a given tlv on the tlv buffer at a given offset */ |
| 24 | void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type, |
| 25 | u16 length) |
| 26 | { |
| 27 | struct channel_tlv *tl = |
| 28 | (struct channel_tlv *)(tlvs_list + offset); |
| 29 | |
| 30 | tl->type = type; |
| 31 | tl->length = length; |
| 32 | } |
| 33 | |
| 34 | /* Clear the mailbox and init the header of the first tlv */ |
| 35 | void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv, |
| 36 | u16 type, u16 length) |
| 37 | { |
| 38 | DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n", |
| 39 | type); |
| 40 | |
| 41 | /* Clear mailbox */ |
| 42 | memset(bp->vf2pf_mbox, 0, sizeof(struct bnx2x_vf_mbx_msg)); |
| 43 | |
| 44 | /* init type and length */ |
| 45 | bnx2x_add_tlv(bp, &first_tlv->tl, 0, type, length); |
| 46 | |
| 47 | /* init first tlv header */ |
| 48 | first_tlv->resp_msg_offset = sizeof(bp->vf2pf_mbox->req); |
| 49 | } |
| 50 | |
| 51 | /* list the types and lengths of the tlvs on the buffer */ |
| 52 | void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list) |
| 53 | { |
| 54 | int i = 1; |
| 55 | struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list; |
| 56 | |
| 57 | while (tlv->type != CHANNEL_TLV_LIST_END) { |
| 58 | /* output tlv */ |
| 59 | DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i, |
| 60 | tlv->type, tlv->length); |
| 61 | |
| 62 | /* advance to next tlv */ |
| 63 | tlvs_list += tlv->length; |
| 64 | |
| 65 | /* cast general tlv list pointer to channel tlv header*/ |
| 66 | tlv = (struct channel_tlv *)tlvs_list; |
| 67 | |
| 68 | i++; |
| 69 | |
| 70 | /* break condition for this loop */ |
| 71 | if (i > MAX_TLVS_IN_LIST) { |
| 72 | WARN(true, "corrupt tlvs"); |
| 73 | return; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /* output last tlv */ |
| 78 | DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i, |
| 79 | tlv->type, tlv->length); |
| 80 | } |