2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
11 #include "ecore_hsi_eth.h"
12 #include "ecore_sriov.h"
13 #include "ecore_l2_api.h"
15 #include "ecore_vfpf_if.h"
16 #include "ecore_status.h"
18 #include "ecore_int.h"
20 #include "ecore_mcp_api.h"
21 #include "ecore_vf_api.h"
23 static void *ecore_vf_pf_prep(struct ecore_hwfn *p_hwfn, u16 type, u16 length)
25 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
28 /* This lock is released when we receive PF's response
29 * in ecore_send_msg2pf().
30 * So, ecore_vf_pf_prep() and ecore_send_msg2pf()
31 * must come in sequence.
33 OSAL_MUTEX_ACQUIRE(&p_iov->mutex);
35 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
36 "preparing to send %s tlv over vf pf channel\n",
37 ecore_channel_tlvs_string[type]);
39 /* Reset Request offset */
40 p_iov->offset = (u8 *)(p_iov->vf2pf_request);
42 /* Clear mailbox - both request and reply */
43 OSAL_MEMSET(p_iov->vf2pf_request, 0, sizeof(union vfpf_tlvs));
44 OSAL_MEMSET(p_iov->pf2vf_reply, 0, sizeof(union pfvf_tlvs));
46 /* Init type and length */
47 p_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset, type, length);
49 /* Init first tlv header */
50 ((struct vfpf_first_tlv *)p_tlv)->reply_address =
51 (u64)p_iov->pf2vf_reply_phys;
56 static int ecore_send_msg2pf(struct ecore_hwfn *p_hwfn,
57 u8 *done, u32 resp_size)
59 struct ustorm_vf_zone *zone_data = (struct ustorm_vf_zone *)
60 ((u8 *)PXP_VF_BAR0_START_USDM_ZONE_B);
61 union vfpf_tlvs *p_req = p_hwfn->vf_iov_info->vf2pf_request;
62 struct ustorm_trigger_vf_zone trigger;
63 int rc = ECORE_SUCCESS, time = 100;
66 /* output tlvs list */
67 ecore_dp_tlv_list(p_hwfn, p_req);
69 /* need to add the END TLV to the message size */
70 resp_size += sizeof(struct channel_list_end_tlv);
72 if (!p_hwfn->p_dev->sriov_info.b_hw_channel) {
73 rc = OSAL_VF_SEND_MSG2PF(p_hwfn->p_dev,
76 p_hwfn->vf_iov_info->pf2vf_reply,
77 sizeof(union vfpf_tlvs), resp_size);
78 /* TODO - no prints about message ? */
82 /* Send TLVs over HW channel */
83 OSAL_MEMSET(&trigger, 0, sizeof(struct ustorm_trigger_vf_zone));
84 trigger.vf_pf_msg_valid = 1;
85 /* TODO - FW should remove this requirement */
86 pf_id = GET_FIELD(p_hwfn->hw_info.concrete_fid, PXP_CONCRETE_FID_PFID);
88 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
89 "VF -> PF [%02x] message: [%08x, %08x] --> %p, %08x --> %p\n",
91 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys),
92 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys),
93 &zone_data->non_trigger.vf_pf_msg_addr,
94 *((u32 *)&trigger), &zone_data->trigger);
97 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.lo,
98 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys));
101 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.hi,
102 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys));
104 /* The message data must be written first, to prevent trigger before
107 OSAL_WMB(p_hwfn->p_dev);
109 REG_WR(p_hwfn, (osal_uintptr_t)&zone_data->trigger,
112 while ((!*done) && time) {
118 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
119 "VF <-- PF Timeout [Type %d]\n",
120 p_req->first_tlv.tl.type);
124 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
125 "PF response: %d [Type %d]\n",
126 *done, p_req->first_tlv.tl.type);
130 OSAL_MUTEX_RELEASE(&p_hwfn->vf_iov_info->mutex);
135 #define VF_ACQUIRE_THRESH 3
136 #define VF_ACQUIRE_MAC_FILTERS 1
137 #define VF_ACQUIRE_MC_FILTERS 10
139 static enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn)
141 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
142 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
143 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
144 struct ecore_vf_acquire_sw_info vf_sw_info;
145 struct vfpf_acquire_tlv *req;
146 int rc = 0, attempts = 0;
147 bool resources_acquired = false;
149 /* @@@ TBD: MichalK take this from somewhere else... */
150 u8 rx_count = 1, tx_count = 1, num_sbs = 1;
151 u8 num_mac = VF_ACQUIRE_MAC_FILTERS, num_mc = VF_ACQUIRE_MC_FILTERS;
153 /* clear mailbox and prep first tlv */
154 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_ACQUIRE, sizeof(*req));
156 /* @@@ TBD: PF may not be ready bnx2x_get_vf_id... */
157 req->vfdev_info.opaque_fid = p_hwfn->hw_info.opaque_fid;
159 req->resc_request.num_rxqs = rx_count;
160 req->resc_request.num_txqs = tx_count;
161 req->resc_request.num_sbs = num_sbs;
162 req->resc_request.num_mac_filters = num_mac;
163 req->resc_request.num_mc_filters = num_mc;
164 req->resc_request.num_vlan_filters = ECORE_ETH_VF_NUM_VLAN_FILTERS;
166 OSAL_MEMSET(&vf_sw_info, 0, sizeof(vf_sw_info));
167 OSAL_VF_FILL_ACQUIRE_RESC_REQ(p_hwfn, &req->resc_request, &vf_sw_info);
169 req->vfdev_info.os_type = vf_sw_info.os_type;
170 req->vfdev_info.driver_version = vf_sw_info.driver_version;
171 req->vfdev_info.fw_major = FW_MAJOR_VERSION;
172 req->vfdev_info.fw_minor = FW_MINOR_VERSION;
173 req->vfdev_info.fw_revision = FW_REVISION_VERSION;
174 req->vfdev_info.fw_engineering = FW_ENGINEERING_VERSION;
176 if (vf_sw_info.override_fw_version)
177 req->vfdev_info.capabilties |= VFPF_ACQUIRE_CAP_OVERRIDE_FW_VER;
179 /* pf 2 vf bulletin board address */
180 req->bulletin_addr = p_iov->bulletin.phys;
181 req->bulletin_size = p_iov->bulletin.size;
183 /* add list termination tlv */
184 ecore_add_tlv(p_hwfn, &p_iov->offset,
185 CHANNEL_TLV_LIST_END,
186 sizeof(struct channel_list_end_tlv));
188 while (!resources_acquired) {
189 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
190 "attempting to acquire resources\n");
192 /* send acquire request */
193 rc = ecore_send_msg2pf(p_hwfn,
194 &resp->hdr.status, sizeof(*resp));
200 /* copy acquire response from buffer to p_hwfn */
201 OSAL_MEMCPY(&p_iov->acquire_resp,
202 resp, sizeof(p_iov->acquire_resp));
206 /* PF agrees to allocate our resources */
207 if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
208 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
209 "resources acquired\n");
210 resources_acquired = true;
211 } /* PF refuses to allocate our resources */
212 else if (resp->hdr.status ==
213 PFVF_STATUS_NO_RESOURCE &&
214 attempts < VF_ACQUIRE_THRESH) {
215 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
216 "PF unwilling to fullfill resource request. Try PF recommended amount\n");
218 /* humble our request */
219 req->resc_request.num_txqs = resp->resc.num_txqs;
220 req->resc_request.num_rxqs = resp->resc.num_rxqs;
221 req->resc_request.num_sbs = resp->resc.num_sbs;
222 req->resc_request.num_mac_filters =
223 resp->resc.num_mac_filters;
224 req->resc_request.num_vlan_filters =
225 resp->resc.num_vlan_filters;
226 req->resc_request.num_mc_filters =
227 resp->resc.num_mc_filters;
229 /* Clear response buffer */
230 OSAL_MEMSET(p_iov->pf2vf_reply, 0,
231 sizeof(union pfvf_tlvs));
234 "PF returned error %d to VF acquisition request\n",
240 rc = OSAL_VF_UPDATE_ACQUIRE_RESC_RESP(p_hwfn, &resp->resc);
242 DP_NOTICE(p_hwfn, true,
243 "VF_UPDATE_ACQUIRE_RESC_RESP Failed: status = 0x%x.\n",
248 /* Update bulletin board size with response from PF */
249 p_iov->bulletin.size = resp->bulletin_size;
252 p_hwfn->p_dev->type = resp->pfdev_info.dev_type;
253 p_hwfn->p_dev->chip_rev = resp->pfdev_info.chip_rev;
255 DP_INFO(p_hwfn, "Chip details - %s%d\n",
256 ECORE_IS_BB(p_hwfn->p_dev) ? "BB" : "AH",
257 CHIP_REV_IS_A0(p_hwfn->p_dev) ? 0 : 1);
259 /* @@@TBD MichalK: Fw ver... */
260 /* strlcpy(p_hwfn->fw_ver, p_hwfn->acquire_resp.pfdev_info.fw_ver,
261 * sizeof(p_hwfn->fw_ver));
264 p_hwfn->p_dev->chip_num = pfdev_info->chip_num & 0xffff;
269 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_dev *p_dev)
271 enum _ecore_status_t rc = ECORE_NOMEM;
272 struct ecore_vf_iov *p_sriov;
273 struct ecore_hwfn *p_hwfn = &p_dev->hwfns[0]; /* @@@TBD CMT */
275 p_dev->num_hwfns = 1; /* @@@TBD CMT must be fixed... */
277 p_hwfn->regview = p_dev->regview;
278 if (p_hwfn->regview == OSAL_NULL) {
280 "regview should be initialized before"
281 " ecore_vf_hw_prepare is called\n");
285 /* Set the doorbell bar. Assumption: regview is set */
286 p_hwfn->doorbells = (u8 OSAL_IOMEM *)p_hwfn->regview +
287 PXP_VF_BAR0_START_DQ;
289 p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn,
290 PXP_VF_BAR0_ME_OPAQUE_ADDRESS);
292 p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn,
293 PXP_VF_BAR0_ME_CONCRETE_ADDRESS);
295 /* Allocate vf sriov info */
296 p_sriov = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL, sizeof(*p_sriov));
298 DP_NOTICE(p_hwfn, true,
299 "Failed to allocate `struct ecore_sriov'\n");
303 OSAL_MEMSET(p_sriov, 0, sizeof(*p_sriov));
305 /* Allocate vf2pf msg */
306 p_sriov->vf2pf_request = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
311 if (!p_sriov->vf2pf_request) {
312 DP_NOTICE(p_hwfn, true,
313 "Failed to allocate `vf2pf_request' DMA memory\n");
317 p_sriov->pf2vf_reply = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
320 sizeof(union pfvf_tlvs));
321 if (!p_sriov->pf2vf_reply) {
322 DP_NOTICE(p_hwfn, true,
323 "Failed to allocate `pf2vf_reply' DMA memory\n");
324 goto free_vf2pf_request;
327 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
328 "VF's Request mailbox [%p virt 0x%" PRIx64 " phys], "
329 "Response mailbox [%p virt 0x%" PRIx64 " phys]\n",
330 p_sriov->vf2pf_request,
331 (u64)p_sriov->vf2pf_request_phys,
332 p_sriov->pf2vf_reply, (u64)p_sriov->pf2vf_reply_phys);
334 /* Allocate Bulletin board */
335 p_sriov->bulletin.size = sizeof(struct ecore_bulletin_content);
336 p_sriov->bulletin.p_virt = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
341 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
342 "VF's bulletin Board [%p virt 0x%" PRIx64 " phys 0x%08x bytes]\n",
343 p_sriov->bulletin.p_virt, (u64)p_sriov->bulletin.phys,
344 p_sriov->bulletin.size);
346 OSAL_MUTEX_ALLOC(p_hwfn, &p_sriov->mutex);
347 OSAL_MUTEX_INIT(&p_sriov->mutex);
349 p_hwfn->vf_iov_info = p_sriov;
351 p_hwfn->hw_info.personality = ECORE_PCI_ETH;
353 /* First VF needs to query for information from PF */
355 rc = ecore_vf_pf_acquire(p_hwfn);
360 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_sriov->vf2pf_request,
361 p_sriov->vf2pf_request_phys,
362 sizeof(union vfpf_tlvs));
364 OSAL_FREE(p_hwfn->p_dev, p_sriov);
369 enum _ecore_status_t ecore_vf_pf_init(struct ecore_hwfn *p_hwfn)
371 p_hwfn->b_int_enabled = 1;
376 /* TEMP TEMP until in HSI */
377 #define TSTORM_QZONE_START PXP_VF_BAR0_START_SDM_ZONE_A
378 #define MSTORM_QZONE_START(dev) (TSTORM_QZONE_START + \
379 (TSTORM_QZONE_SIZE * NUM_OF_L2_QUEUES(dev)))
380 #define USTORM_QZONE_START(dev) (MSTORM_QZONE_START + \
381 (MSTORM_QZONE_SIZE * NUM_OF_L2_QUEUES(dev)))
383 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
388 dma_addr_t bd_chain_phys_addr,
389 dma_addr_t cqe_pbl_addr,
391 void OSAL_IOMEM **pp_prod)
393 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
394 struct vfpf_start_rxq_tlv *req;
395 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
398 u64 init_prod_val = 0;
400 /* clear mailbox and prep first tlv */
401 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_RXQ, sizeof(*req));
403 /* @@@TBD MichalK TPA */
405 req->rx_qid = rx_qid;
406 req->cqe_pbl_addr = cqe_pbl_addr;
407 req->cqe_pbl_size = cqe_pbl_size;
408 req->rxq_addr = bd_chain_phys_addr;
410 req->sb_index = sb_index;
411 req->hc_rate = 0; /* @@@TBD MichalK -> host coalescing! */
412 req->bd_max_bytes = bd_max_bytes;
413 req->stat_id = -1; /* No stats at the moment */
415 /* add list termination tlv */
416 ecore_add_tlv(p_hwfn, &p_iov->offset,
417 CHANNEL_TLV_LIST_END,
418 sizeof(struct channel_list_end_tlv));
421 hw_qid = p_iov->acquire_resp.resc.hw_qid[rx_qid];
423 *pp_prod = (u8 OSAL_IOMEM *)p_hwfn->regview +
424 MSTORM_QZONE_START(p_hwfn->p_dev) +
425 (hw_qid) * MSTORM_QZONE_SIZE +
426 OFFSETOF(struct mstorm_eth_queue_zone, rx_producers);
428 /* Init the rcq, rx bd and rx sge (if valid) producers to 0 */
429 __internal_ram_wr(p_hwfn, *pp_prod, sizeof(u64),
430 (u32 *)(&init_prod_val));
433 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
437 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
443 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
444 u16 rx_qid, bool cqe_completion)
446 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
447 struct vfpf_stop_rxqs_tlv *req;
448 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
451 /* clear mailbox and prep first tlv */
452 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_RXQS, sizeof(*req));
454 /* @@@TBD MichalK TPA */
456 /* @@@TBD MichalK - relevant ???
457 * flags VFPF_QUEUE_FLG_OV VFPF_QUEUE_FLG_VLAN
459 req->rx_qid = rx_qid;
461 req->cqe_completion = cqe_completion;
463 /* add list termination tlv */
464 ecore_add_tlv(p_hwfn, &p_iov->offset,
465 CHANNEL_TLV_LIST_END,
466 sizeof(struct channel_list_end_tlv));
468 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
472 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
478 enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
484 void OSAL_IOMEM **pp_doorbell)
486 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
487 struct vfpf_start_txq_tlv *req;
488 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
491 /* clear mailbox and prep first tlv */
492 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_TXQ, sizeof(*req));
494 /* @@@TBD MichalK TPA */
496 req->tx_qid = tx_queue_id;
499 req->pbl_addr = pbl_addr;
500 req->pbl_size = pbl_size;
502 req->sb_index = sb_index;
503 req->hc_rate = 0; /* @@@TBD MichalK -> host coalescing! */
504 req->flags = 0; /* @@@TBD MichalK -> flags... */
506 /* add list termination tlv */
507 ecore_add_tlv(p_hwfn, &p_iov->offset,
508 CHANNEL_TLV_LIST_END,
509 sizeof(struct channel_list_end_tlv));
511 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
515 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
519 u8 cid = p_iov->acquire_resp.resc.cid[tx_queue_id];
521 *pp_doorbell = (u8 OSAL_IOMEM *)p_hwfn->doorbells +
522 DB_ADDR_VF(cid, DQ_DEMS_LEGACY);
528 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, u16 tx_qid)
530 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
531 struct vfpf_stop_txqs_tlv *req;
532 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
535 /* clear mailbox and prep first tlv */
536 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_TXQS, sizeof(*req));
538 /* @@@TBD MichalK TPA */
540 /* @@@TBD MichalK - relevant ??? flags
541 * VFPF_QUEUE_FLG_OV VFPF_QUEUE_FLG_VLAN
543 req->tx_qid = tx_qid;
546 /* add list termination tlv */
547 ecore_add_tlv(p_hwfn, &p_iov->offset,
548 CHANNEL_TLV_LIST_END,
549 sizeof(struct channel_list_end_tlv));
551 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
555 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
561 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
564 u8 comp_cqe_flg, u8 comp_event_flg)
566 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
567 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
568 struct vfpf_update_rxq_tlv *req;
571 /* clear mailbox and prep first tlv */
572 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UPDATE_RXQ, sizeof(*req));
574 req->rx_qid = rx_queue_id;
575 req->num_rxqs = num_rxqs;
578 req->flags |= VFPF_RXQ_UPD_COMPLETE_CQE_FLAG;
580 req->flags |= VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG;
582 /* add list termination tlv */
583 ecore_add_tlv(p_hwfn, &p_iov->offset,
584 CHANNEL_TLV_LIST_END,
585 sizeof(struct channel_list_end_tlv));
587 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
591 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
598 ecore_vf_pf_vport_start(struct ecore_hwfn *p_hwfn, u8 vport_id,
599 u16 mtu, u8 inner_vlan_removal,
600 enum ecore_tpa_mode tpa_mode, u8 max_buffers_per_cqe,
603 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
604 struct vfpf_vport_start_tlv *req;
605 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
608 /* clear mailbox and prep first tlv */
609 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_START, sizeof(*req));
612 req->vport_id = vport_id;
613 req->inner_vlan_removal = inner_vlan_removal;
614 req->tpa_mode = tpa_mode;
615 req->max_buffers_per_cqe = max_buffers_per_cqe;
616 req->only_untagged = only_untagged;
619 for (i = 0; i < p_hwfn->vf_iov_info->acquire_resp.resc.num_sbs; i++)
620 if (p_hwfn->sbs_info[i])
621 req->sb_addr[i] = p_hwfn->sbs_info[i]->sb_phys;
623 /* add list termination tlv */
624 ecore_add_tlv(p_hwfn, &p_iov->offset,
625 CHANNEL_TLV_LIST_END,
626 sizeof(struct channel_list_end_tlv));
628 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
632 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
638 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn)
640 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
641 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
644 /* clear mailbox and prep first tlv */
645 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_TEARDOWN,
646 sizeof(struct vfpf_first_tlv));
648 /* add list termination tlv */
649 ecore_add_tlv(p_hwfn, &p_iov->offset,
650 CHANNEL_TLV_LIST_END,
651 sizeof(struct channel_list_end_tlv));
653 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
657 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
664 ecore_vf_handle_vp_update_tlvs_resp(struct ecore_hwfn *p_hwfn,
665 struct ecore_sp_vport_update_params *p_data)
667 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
668 struct pfvf_def_resp_tlv *p_resp;
671 if (p_data->update_vport_active_rx_flg ||
672 p_data->update_vport_active_tx_flg) {
673 tlv = CHANNEL_TLV_VPORT_UPDATE_ACTIVATE;
674 p_resp = (struct pfvf_def_resp_tlv *)
675 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
676 if (p_resp && p_resp->hdr.status)
677 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
678 "VP update activate tlv configured\n");
680 DP_NOTICE(p_hwfn, true,
681 "VP update activate tlv config failed\n");
684 if (p_data->update_tx_switching_flg) {
685 tlv = CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH;
686 p_resp = (struct pfvf_def_resp_tlv *)
687 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
688 if (p_resp && p_resp->hdr.status)
689 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
690 "VP update tx switch tlv configured\n");
692 else if (CHIP_REV_IS_FPGA(p_hwfn->p_dev))
693 DP_NOTICE(p_hwfn, false,
694 "FPGA: Skip checking whether PF"
695 " replied to Tx-switching request\n");
698 DP_NOTICE(p_hwfn, true,
699 "VP update tx switch tlv config failed\n");
702 if (p_data->update_inner_vlan_removal_flg) {
703 tlv = CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP;
704 p_resp = (struct pfvf_def_resp_tlv *)
705 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
706 if (p_resp && p_resp->hdr.status)
707 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
708 "VP update vlan strip tlv configured\n");
710 DP_NOTICE(p_hwfn, true,
711 "VP update vlan strip tlv config failed\n");
714 if (p_data->update_approx_mcast_flg) {
715 tlv = CHANNEL_TLV_VPORT_UPDATE_MCAST;
716 p_resp = (struct pfvf_def_resp_tlv *)
717 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
718 if (p_resp && p_resp->hdr.status)
719 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
720 "VP update mcast tlv configured\n");
722 DP_NOTICE(p_hwfn, true,
723 "VP update mcast tlv config failed\n");
726 if (p_data->accept_flags.update_rx_mode_config ||
727 p_data->accept_flags.update_tx_mode_config) {
728 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM;
729 p_resp = (struct pfvf_def_resp_tlv *)
730 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
731 if (p_resp && p_resp->hdr.status)
732 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
733 "VP update accept_mode tlv configured\n");
735 DP_NOTICE(p_hwfn, true,
736 "VP update accept_mode tlv config failed\n");
739 if (p_data->rss_params) {
740 tlv = CHANNEL_TLV_VPORT_UPDATE_RSS;
741 p_resp = (struct pfvf_def_resp_tlv *)
742 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
743 if (p_resp && p_resp->hdr.status)
744 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
745 "VP update rss tlv configured\n");
747 DP_NOTICE(p_hwfn, true,
748 "VP update rss tlv config failed\n");
751 if (p_data->sge_tpa_params) {
752 tlv = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA;
753 p_resp = (struct pfvf_def_resp_tlv *)
754 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
755 if (p_resp && p_resp->hdr.status)
756 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
757 "VP update sge tpa tlv configured\n");
759 DP_NOTICE(p_hwfn, true,
760 "VP update sge tpa tlv config failed\n");
765 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
766 struct ecore_sp_vport_update_params *p_params)
768 struct vfpf_vport_update_accept_any_vlan_tlv *p_any_vlan_tlv;
769 struct vfpf_vport_update_accept_param_tlv *p_accept_tlv;
770 struct vfpf_vport_update_tx_switch_tlv *p_tx_switch_tlv;
771 struct vfpf_vport_update_mcast_bin_tlv *p_mcast_tlv;
772 struct vfpf_vport_update_vlan_strip_tlv *p_vlan_tlv;
773 struct vfpf_vport_update_sge_tpa_tlv *p_sge_tpa_tlv;
774 struct vfpf_vport_update_activate_tlv *p_act_tlv;
775 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
776 struct vfpf_vport_update_rss_tlv *p_rss_tlv;
777 struct vfpf_vport_update_tlv *req;
778 struct pfvf_def_resp_tlv *resp;
779 u8 update_rx, update_tx;
784 resp = &p_iov->pf2vf_reply->default_resp;
785 resp_size = sizeof(*resp);
787 update_rx = p_params->update_vport_active_rx_flg;
788 update_tx = p_params->update_vport_active_tx_flg;
790 /* clear mailbox and prep header tlv */
791 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_UPDATE, sizeof(*req));
793 /* Prepare extended tlvs */
794 if (update_rx || update_tx) {
795 size = sizeof(struct vfpf_vport_update_activate_tlv);
796 p_act_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
797 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
799 resp_size += sizeof(struct pfvf_def_resp_tlv);
802 p_act_tlv->update_rx = update_rx;
803 p_act_tlv->active_rx = p_params->vport_active_rx_flg;
807 p_act_tlv->update_tx = update_tx;
808 p_act_tlv->active_tx = p_params->vport_active_tx_flg;
812 if (p_params->update_inner_vlan_removal_flg) {
813 size = sizeof(struct vfpf_vport_update_vlan_strip_tlv);
814 p_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
815 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
817 resp_size += sizeof(struct pfvf_def_resp_tlv);
819 p_vlan_tlv->remove_vlan = p_params->inner_vlan_removal_flg;
822 if (p_params->update_tx_switching_flg) {
823 size = sizeof(struct vfpf_vport_update_tx_switch_tlv);
824 tlv = CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH;
825 p_tx_switch_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
827 resp_size += sizeof(struct pfvf_def_resp_tlv);
829 p_tx_switch_tlv->tx_switching = p_params->tx_switching_flg;
832 if (p_params->update_approx_mcast_flg) {
833 size = sizeof(struct vfpf_vport_update_mcast_bin_tlv);
834 p_mcast_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
835 CHANNEL_TLV_VPORT_UPDATE_MCAST,
837 resp_size += sizeof(struct pfvf_def_resp_tlv);
839 OSAL_MEMCPY(p_mcast_tlv->bins, p_params->bins,
840 sizeof(unsigned long) *
841 ETH_MULTICAST_MAC_BINS_IN_REGS);
844 update_rx = p_params->accept_flags.update_rx_mode_config;
845 update_tx = p_params->accept_flags.update_tx_mode_config;
847 if (update_rx || update_tx) {
848 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM;
849 size = sizeof(struct vfpf_vport_update_accept_param_tlv);
850 p_accept_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset, tlv, size);
851 resp_size += sizeof(struct pfvf_def_resp_tlv);
854 p_accept_tlv->update_rx_mode = update_rx;
855 p_accept_tlv->rx_accept_filter =
856 p_params->accept_flags.rx_accept_filter;
860 p_accept_tlv->update_tx_mode = update_tx;
861 p_accept_tlv->tx_accept_filter =
862 p_params->accept_flags.tx_accept_filter;
866 if (p_params->rss_params) {
867 struct ecore_rss_params *rss_params = p_params->rss_params;
869 size = sizeof(struct vfpf_vport_update_rss_tlv);
870 p_rss_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
871 CHANNEL_TLV_VPORT_UPDATE_RSS, size);
872 resp_size += sizeof(struct pfvf_def_resp_tlv);
874 if (rss_params->update_rss_config)
875 p_rss_tlv->update_rss_flags |=
876 VFPF_UPDATE_RSS_CONFIG_FLAG;
877 if (rss_params->update_rss_capabilities)
878 p_rss_tlv->update_rss_flags |=
879 VFPF_UPDATE_RSS_CAPS_FLAG;
880 if (rss_params->update_rss_ind_table)
881 p_rss_tlv->update_rss_flags |=
882 VFPF_UPDATE_RSS_IND_TABLE_FLAG;
883 if (rss_params->update_rss_key)
884 p_rss_tlv->update_rss_flags |= VFPF_UPDATE_RSS_KEY_FLAG;
886 p_rss_tlv->rss_enable = rss_params->rss_enable;
887 p_rss_tlv->rss_caps = rss_params->rss_caps;
888 p_rss_tlv->rss_table_size_log = rss_params->rss_table_size_log;
889 OSAL_MEMCPY(p_rss_tlv->rss_ind_table, rss_params->rss_ind_table,
890 sizeof(rss_params->rss_ind_table));
891 OSAL_MEMCPY(p_rss_tlv->rss_key, rss_params->rss_key,
892 sizeof(rss_params->rss_key));
895 if (p_params->update_accept_any_vlan_flg) {
896 size = sizeof(struct vfpf_vport_update_accept_any_vlan_tlv);
897 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN;
898 p_any_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
901 resp_size += sizeof(struct pfvf_def_resp_tlv);
902 p_any_vlan_tlv->accept_any_vlan = p_params->accept_any_vlan;
903 p_any_vlan_tlv->update_accept_any_vlan_flg =
904 p_params->update_accept_any_vlan_flg;
907 if (p_params->sge_tpa_params) {
908 struct ecore_sge_tpa_params *sge_tpa_params =
909 p_params->sge_tpa_params;
911 size = sizeof(struct vfpf_vport_update_sge_tpa_tlv);
912 p_sge_tpa_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
913 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
915 resp_size += sizeof(struct pfvf_def_resp_tlv);
917 if (sge_tpa_params->update_tpa_en_flg)
918 p_sge_tpa_tlv->update_sge_tpa_flags |=
919 VFPF_UPDATE_TPA_EN_FLAG;
920 if (sge_tpa_params->update_tpa_param_flg)
921 p_sge_tpa_tlv->update_sge_tpa_flags |=
922 VFPF_UPDATE_TPA_PARAM_FLAG;
924 if (sge_tpa_params->tpa_ipv4_en_flg)
925 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV4_EN_FLAG;
926 if (sge_tpa_params->tpa_ipv6_en_flg)
927 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV6_EN_FLAG;
928 if (sge_tpa_params->tpa_pkt_split_flg)
929 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_PKT_SPLIT_FLAG;
930 if (sge_tpa_params->tpa_hdr_data_split_flg)
931 p_sge_tpa_tlv->sge_tpa_flags |=
932 VFPF_TPA_HDR_DATA_SPLIT_FLAG;
933 if (sge_tpa_params->tpa_gro_consistent_flg)
934 p_sge_tpa_tlv->sge_tpa_flags |=
935 VFPF_TPA_GRO_CONSIST_FLAG;
937 p_sge_tpa_tlv->tpa_max_aggs_num =
938 sge_tpa_params->tpa_max_aggs_num;
939 p_sge_tpa_tlv->tpa_max_size = sge_tpa_params->tpa_max_size;
940 p_sge_tpa_tlv->tpa_min_size_to_start =
941 sge_tpa_params->tpa_min_size_to_start;
942 p_sge_tpa_tlv->tpa_min_size_to_cont =
943 sge_tpa_params->tpa_min_size_to_cont;
945 p_sge_tpa_tlv->max_buffers_per_cqe =
946 sge_tpa_params->max_buffers_per_cqe;
949 /* add list termination tlv */
950 ecore_add_tlv(p_hwfn, &p_iov->offset,
951 CHANNEL_TLV_LIST_END,
952 sizeof(struct channel_list_end_tlv));
954 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, resp_size);
958 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
961 ecore_vf_handle_vp_update_tlvs_resp(p_hwfn, p_params);
966 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn)
968 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
969 struct vfpf_first_tlv *req;
970 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
973 /* clear mailbox and prep first tlv */
974 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_CLOSE, sizeof(*req));
976 /* add list termination tlv */
977 ecore_add_tlv(p_hwfn, &p_iov->offset,
978 CHANNEL_TLV_LIST_END,
979 sizeof(struct channel_list_end_tlv));
981 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
985 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
988 p_hwfn->b_int_enabled = 0;
990 return ECORE_SUCCESS;
993 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn)
995 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
996 struct vfpf_first_tlv *req;
997 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
1001 /* clear mailbox and prep first tlv */
1002 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_RELEASE, sizeof(*req));
1004 /* add list termination tlv */
1005 ecore_add_tlv(p_hwfn, &p_iov->offset,
1006 CHANNEL_TLV_LIST_END,
1007 sizeof(struct channel_list_end_tlv));
1009 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1011 if (rc == ECORE_SUCCESS && resp->hdr.status != PFVF_STATUS_SUCCESS)
1014 p_hwfn->b_int_enabled = 0;
1016 /* TODO - might need to revise this for 100g */
1017 if (IS_LEAD_HWFN(p_hwfn))
1018 OSAL_MUTEX_DEALLOC(&p_iov->mutex);
1020 if (p_iov->vf2pf_request)
1021 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1022 p_iov->vf2pf_request,
1023 p_iov->vf2pf_request_phys,
1024 sizeof(union vfpf_tlvs));
1025 if (p_iov->pf2vf_reply)
1026 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1028 p_iov->pf2vf_reply_phys,
1029 sizeof(union pfvf_tlvs));
1031 if (p_iov->bulletin.p_virt) {
1032 size = sizeof(struct ecore_bulletin_content);
1033 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1034 p_iov->bulletin.p_virt,
1035 p_iov->bulletin.phys, size);
1038 OSAL_FREE(p_hwfn->p_dev, p_hwfn->vf_iov_info);
1039 p_hwfn->vf_iov_info = OSAL_NULL;
1044 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
1045 struct ecore_filter_mcast *p_filter_cmd)
1047 struct ecore_sp_vport_update_params sp_params;
1050 OSAL_MEMSET(&sp_params, 0, sizeof(sp_params));
1051 sp_params.update_approx_mcast_flg = 1;
1053 if (p_filter_cmd->opcode == ECORE_FILTER_ADD) {
1054 for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) {
1057 bit = ecore_mcast_bin_from_mac(p_filter_cmd->mac[i]);
1058 OSAL_SET_BIT(bit, sp_params.bins);
1062 ecore_vf_pf_vport_update(p_hwfn, &sp_params);
1065 enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn *p_hwfn,
1066 struct ecore_filter_ucast
1069 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1070 struct vfpf_ucast_filter_tlv *req;
1071 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
1075 if (p_ucast->opcode == ECORE_FILTER_MOVE) {
1076 DP_NOTICE(p_hwfn, true,
1077 "VFs don't support Moving of filters\n");
1081 /* clear mailbox and prep first tlv */
1082 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UCAST_FILTER, sizeof(*req));
1083 req->opcode = (u8)p_ucast->opcode;
1084 req->type = (u8)p_ucast->type;
1085 OSAL_MEMCPY(req->mac, p_ucast->mac, ETH_ALEN);
1086 req->vlan = p_ucast->vlan;
1088 /* add list termination tlv */
1089 ecore_add_tlv(p_hwfn, &p_iov->offset,
1090 CHANNEL_TLV_LIST_END,
1091 sizeof(struct channel_list_end_tlv));
1093 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1097 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
1100 return ECORE_SUCCESS;
1103 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn)
1105 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1106 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
1109 /* clear mailbox and prep first tlv */
1110 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_INT_CLEANUP,
1111 sizeof(struct vfpf_first_tlv));
1113 /* add list termination tlv */
1114 ecore_add_tlv(p_hwfn, &p_iov->offset,
1115 CHANNEL_TLV_LIST_END,
1116 sizeof(struct channel_list_end_tlv));
1118 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1122 if (resp->hdr.status != PFVF_STATUS_SUCCESS)
1125 return ECORE_SUCCESS;
1128 enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn,
1131 struct ecore_bulletin_content shadow;
1132 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1133 u32 crc, crc_size = sizeof(p_iov->bulletin.p_virt->crc);
1137 /* Need to guarantee PF is not in the middle of writing it */
1138 OSAL_MEMCPY(&shadow, p_iov->bulletin.p_virt, p_iov->bulletin.size);
1140 /* If version did not update, no need to do anything */
1141 if (shadow.version == p_iov->bulletin_shadow.version)
1142 return ECORE_SUCCESS;
1144 /* Verify the bulletin we see is valid */
1145 crc = ecore_crc32(0, (u8 *)&shadow + crc_size,
1146 p_iov->bulletin.size - crc_size);
1147 if (crc != shadow.crc)
1150 /* Set the shadow bulletin and process it */
1151 OSAL_MEMCPY(&p_iov->bulletin_shadow, &shadow, p_iov->bulletin.size);
1153 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
1154 "Read a bulletin update %08x\n", shadow.version);
1158 return ECORE_SUCCESS;
1161 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id)
1163 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1166 DP_NOTICE(p_hwfn, true, "vf_sriov_info isn't initialized\n");
1170 return p_iov->acquire_resp.resc.hw_sbs[sb_id].hw_sb_id;
1173 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1174 struct ecore_mcp_link_params *p_params,
1175 struct ecore_bulletin_content *p_bulletin)
1177 OSAL_MEMSET(p_params, 0, sizeof(*p_params));
1179 p_params->speed.autoneg = p_bulletin->req_autoneg;
1180 p_params->speed.advertised_speeds = p_bulletin->req_adv_speed;
1181 p_params->speed.forced_speed = p_bulletin->req_forced_speed;
1182 p_params->pause.autoneg = p_bulletin->req_autoneg_pause;
1183 p_params->pause.forced_rx = p_bulletin->req_forced_rx;
1184 p_params->pause.forced_tx = p_bulletin->req_forced_tx;
1185 p_params->loopback_mode = p_bulletin->req_loopback;
1188 void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1189 struct ecore_mcp_link_params *params)
1191 __ecore_vf_get_link_params(p_hwfn, params,
1192 &p_hwfn->vf_iov_info->bulletin_shadow);
1195 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1196 struct ecore_mcp_link_state *p_link,
1197 struct ecore_bulletin_content *p_bulletin)
1199 OSAL_MEMSET(p_link, 0, sizeof(*p_link));
1201 p_link->link_up = p_bulletin->link_up;
1202 p_link->speed = p_bulletin->speed;
1203 p_link->full_duplex = p_bulletin->full_duplex;
1204 p_link->an = p_bulletin->autoneg;
1205 p_link->an_complete = p_bulletin->autoneg_complete;
1206 p_link->parallel_detection = p_bulletin->parallel_detection;
1207 p_link->pfc_enabled = p_bulletin->pfc_enabled;
1208 p_link->partner_adv_speed = p_bulletin->partner_adv_speed;
1209 p_link->partner_tx_flow_ctrl_en = p_bulletin->partner_tx_flow_ctrl_en;
1210 p_link->partner_rx_flow_ctrl_en = p_bulletin->partner_rx_flow_ctrl_en;
1211 p_link->partner_adv_pause = p_bulletin->partner_adv_pause;
1212 p_link->sfp_tx_fault = p_bulletin->sfp_tx_fault;
1215 void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1216 struct ecore_mcp_link_state *link)
1218 __ecore_vf_get_link_state(p_hwfn, link,
1219 &p_hwfn->vf_iov_info->bulletin_shadow);
1222 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1223 struct ecore_mcp_link_capabilities *p_link_caps,
1224 struct ecore_bulletin_content *p_bulletin)
1226 OSAL_MEMSET(p_link_caps, 0, sizeof(*p_link_caps));
1227 p_link_caps->speed_capabilities = p_bulletin->capability_speed;
1230 void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1231 struct ecore_mcp_link_capabilities *p_link_caps)
1233 __ecore_vf_get_link_caps(p_hwfn, p_link_caps,
1234 &p_hwfn->vf_iov_info->bulletin_shadow);
1237 void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, u8 *num_rxqs)
1239 *num_rxqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_rxqs;
1242 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, u8 *port_mac)
1244 OSAL_MEMCPY(port_mac,
1245 p_hwfn->vf_iov_info->acquire_resp.pfdev_info.port_mac,
1249 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn,
1250 u8 *num_vlan_filters)
1252 struct ecore_vf_iov *p_vf;
1254 p_vf = p_hwfn->vf_iov_info;
1255 *num_vlan_filters = p_vf->acquire_resp.resc.num_vlan_filters;
1259 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn,
1262 struct ecore_vf_iov *p_vf;
1264 p_vf = p_hwfn->vf_iov_info;
1265 *num_mac = p_vf->acquire_resp.resc.num_mac_filters;
1268 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac)
1270 struct ecore_bulletin_content *bulletin;
1272 bulletin = &p_hwfn->vf_iov_info->bulletin_shadow;
1273 if (!(bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)))
1276 /* Forbid VF from changing a MAC enforced by PF */
1277 if (OSAL_MEMCMP(bulletin->mac, mac, ETH_ALEN))
1283 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
1286 struct ecore_bulletin_content *bulletin;
1288 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1290 if (bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)) {
1293 } else if (bulletin->valid_bitmap & (1 << VFPF_BULLETIN_MAC_ADDR)) {
1300 OSAL_MEMCPY(dst_mac, bulletin->mac, ETH_ALEN);
1305 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid)
1307 struct ecore_bulletin_content *bulletin;
1309 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1311 if (!(bulletin->valid_bitmap & (1 << VLAN_ADDR_FORCED)))
1315 *dst_pvid = bulletin->pvid;
1320 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn,
1321 u16 *fw_major, u16 *fw_minor, u16 *fw_rev,
1324 struct pf_vf_pfdev_info *info;
1326 info = &p_hwfn->vf_iov_info->acquire_resp.pfdev_info;
1328 *fw_major = info->fw_major;
1329 *fw_minor = info->fw_minor;
1330 *fw_rev = info->fw_rev;
1331 *fw_eng = info->fw_eng;