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 void ecore_vf_pf_req_end(struct ecore_hwfn *p_hwfn,
57 enum _ecore_status_t req_status)
59 union pfvf_tlvs *resp = p_hwfn->vf_iov_info->pf2vf_reply;
61 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
62 "VF request status = 0x%x, PF reply status = 0x%x\n",
63 req_status, resp->default_resp.hdr.status);
65 OSAL_MUTEX_RELEASE(&p_hwfn->vf_iov_info->mutex);
68 static enum _ecore_status_t
69 ecore_send_msg2pf(struct ecore_hwfn *p_hwfn,
70 u8 *done, u32 resp_size)
72 union vfpf_tlvs *p_req = p_hwfn->vf_iov_info->vf2pf_request;
73 struct ustorm_trigger_vf_zone trigger;
74 struct ustorm_vf_zone *zone_data;
75 enum _ecore_status_t rc = ECORE_SUCCESS;
78 zone_data = (struct ustorm_vf_zone *)PXP_VF_BAR0_START_USDM_ZONE_B;
80 /* output tlvs list */
81 ecore_dp_tlv_list(p_hwfn, p_req);
83 /* need to add the END TLV to the message size */
84 resp_size += sizeof(struct channel_list_end_tlv);
86 /* Send TLVs over HW channel */
87 OSAL_MEMSET(&trigger, 0, sizeof(struct ustorm_trigger_vf_zone));
88 trigger.vf_pf_msg_valid = 1;
90 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
91 "VF -> PF [%02x] message: [%08x, %08x] --> %p,"
93 GET_FIELD(p_hwfn->hw_info.concrete_fid,
94 PXP_CONCRETE_FID_PFID),
95 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys),
96 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys),
97 &zone_data->non_trigger.vf_pf_msg_addr,
98 *((u32 *)&trigger), &zone_data->trigger);
101 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.lo,
102 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys));
105 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.hi,
106 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys));
108 /* The message data must be written first, to prevent trigger before
111 OSAL_WMB(p_hwfn->p_dev);
113 REG_WR(p_hwfn, (osal_uintptr_t)&zone_data->trigger,
116 /* When PF would be done with the response, it would write back to the
117 * `done' address. Poll until then.
119 while ((!*done) && time) {
125 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
126 "VF <-- PF Timeout [Type %d]\n",
127 p_req->first_tlv.tl.type);
131 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
132 "PF response: %d [Type %d]\n",
133 *done, p_req->first_tlv.tl.type);
139 #define VF_ACQUIRE_THRESH 3
140 static void ecore_vf_pf_acquire_reduce_resc(struct ecore_hwfn *p_hwfn,
141 struct vf_pf_resc_request *p_req,
142 struct pf_vf_resc *p_resp)
144 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
145 "PF unwilling to fullill resource request: rxq [%02x/%02x]"
146 " txq [%02x/%02x] sbs [%02x/%02x] mac [%02x/%02x]"
147 " vlan [%02x/%02x] mc [%02x/%02x]."
148 " Try PF recommended amount\n",
149 p_req->num_rxqs, p_resp->num_rxqs,
150 p_req->num_rxqs, p_resp->num_txqs,
151 p_req->num_sbs, p_resp->num_sbs,
152 p_req->num_mac_filters, p_resp->num_mac_filters,
153 p_req->num_vlan_filters, p_resp->num_vlan_filters,
154 p_req->num_mc_filters, p_resp->num_mc_filters);
156 /* humble our request */
157 p_req->num_txqs = p_resp->num_txqs;
158 p_req->num_rxqs = p_resp->num_rxqs;
159 p_req->num_sbs = p_resp->num_sbs;
160 p_req->num_mac_filters = p_resp->num_mac_filters;
161 p_req->num_vlan_filters = p_resp->num_vlan_filters;
162 p_req->num_mc_filters = p_resp->num_mc_filters;
165 static enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn)
167 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
168 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
169 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
170 struct ecore_vf_acquire_sw_info vf_sw_info;
171 struct vf_pf_resc_request *p_resc;
172 bool resources_acquired = false;
173 struct vfpf_acquire_tlv *req;
175 enum _ecore_status_t rc = ECORE_SUCCESS;
177 /* clear mailbox and prep first tlv */
178 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_ACQUIRE, sizeof(*req));
179 p_resc = &req->resc_request;
181 /* @@@ TBD: PF may not be ready bnx2x_get_vf_id... */
182 req->vfdev_info.opaque_fid = p_hwfn->hw_info.opaque_fid;
184 p_resc->num_rxqs = ECORE_MAX_VF_CHAINS_PER_PF;
185 p_resc->num_txqs = ECORE_MAX_VF_CHAINS_PER_PF;
186 p_resc->num_sbs = ECORE_MAX_VF_CHAINS_PER_PF;
187 p_resc->num_mac_filters = ECORE_ETH_VF_NUM_MAC_FILTERS;
188 p_resc->num_vlan_filters = ECORE_ETH_VF_NUM_VLAN_FILTERS;
190 OSAL_MEMSET(&vf_sw_info, 0, sizeof(vf_sw_info));
191 OSAL_VF_FILL_ACQUIRE_RESC_REQ(p_hwfn, &req->resc_request, &vf_sw_info);
193 req->vfdev_info.os_type = vf_sw_info.os_type;
194 req->vfdev_info.driver_version = vf_sw_info.driver_version;
195 req->vfdev_info.fw_major = FW_MAJOR_VERSION;
196 req->vfdev_info.fw_minor = FW_MINOR_VERSION;
197 req->vfdev_info.fw_revision = FW_REVISION_VERSION;
198 req->vfdev_info.fw_engineering = FW_ENGINEERING_VERSION;
199 req->vfdev_info.eth_fp_hsi_major = ETH_HSI_VER_MAJOR;
200 req->vfdev_info.eth_fp_hsi_minor = ETH_HSI_VER_MINOR;
202 /* Fill capability field with any non-deprecated config we support */
203 req->vfdev_info.capabilities |= VFPF_ACQUIRE_CAP_100G;
205 /* pf 2 vf bulletin board address */
206 req->bulletin_addr = p_iov->bulletin.phys;
207 req->bulletin_size = p_iov->bulletin.size;
209 /* add list termination tlv */
210 ecore_add_tlv(p_hwfn, &p_iov->offset,
211 CHANNEL_TLV_LIST_END,
212 sizeof(struct channel_list_end_tlv));
214 while (!resources_acquired) {
215 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
216 "attempting to acquire resources\n");
218 /* Clear response buffer, as this might be a re-send */
219 OSAL_MEMSET(p_iov->pf2vf_reply, 0,
220 sizeof(union pfvf_tlvs));
222 /* send acquire request */
223 rc = ecore_send_msg2pf(p_hwfn,
224 &resp->hdr.status, sizeof(*resp));
230 /* copy acquire response from buffer to p_hwfn */
231 OSAL_MEMCPY(&p_iov->acquire_resp,
232 resp, sizeof(p_iov->acquire_resp));
236 if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
237 /* PF agrees to allocate our resources */
238 if (!(resp->pfdev_info.capabilities &
239 PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE)) {
240 /* It's possible legacy PF mistakenly accepted;
241 * but we don't care - simply mark it as
242 * legacy and continue.
244 req->vfdev_info.capabilities |=
245 VFPF_ACQUIRE_CAP_PRE_FP_HSI;
247 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
248 "resources acquired\n");
249 resources_acquired = true;
250 } /* PF refuses to allocate our resources */
251 else if (resp->hdr.status == PFVF_STATUS_NO_RESOURCE &&
252 attempts < VF_ACQUIRE_THRESH) {
253 ecore_vf_pf_acquire_reduce_resc(p_hwfn, p_resc,
256 } else if (resp->hdr.status == PFVF_STATUS_NOT_SUPPORTED) {
257 if (pfdev_info->major_fp_hsi &&
258 (pfdev_info->major_fp_hsi != ETH_HSI_VER_MAJOR)) {
259 DP_NOTICE(p_hwfn, false,
260 "PF uses an incompatible fastpath HSI"
261 " %02x.%02x [VF requires %02x.%02x]."
262 " Please change to a VF driver using"
264 pfdev_info->major_fp_hsi,
265 pfdev_info->minor_fp_hsi,
266 ETH_HSI_VER_MAJOR, ETH_HSI_VER_MINOR,
267 pfdev_info->major_fp_hsi);
272 if (!pfdev_info->major_fp_hsi) {
273 if (req->vfdev_info.capabilities &
274 VFPF_ACQUIRE_CAP_PRE_FP_HSI) {
275 DP_NOTICE(p_hwfn, false,
276 "PF uses very old drivers."
277 " Please change to a VF"
278 " driver using no later than"
284 "PF is old - try re-acquire to"
285 " see if it supports FW-version"
287 req->vfdev_info.capabilities |=
288 VFPF_ACQUIRE_CAP_PRE_FP_HSI;
293 /* If PF/VF are using same Major, PF must have had
294 * it's reasons. Simply fail.
296 DP_NOTICE(p_hwfn, false,
297 "PF rejected acquisition by VF\n");
302 "PF returned err %d to VF acquisition request\n",
309 /* Mark the PF as legacy, if needed */
310 if (req->vfdev_info.capabilities &
311 VFPF_ACQUIRE_CAP_PRE_FP_HSI)
312 p_iov->b_pre_fp_hsi = true;
314 rc = OSAL_VF_UPDATE_ACQUIRE_RESC_RESP(p_hwfn, &resp->resc);
316 DP_NOTICE(p_hwfn, true,
317 "VF_UPDATE_ACQUIRE_RESC_RESP Failed:"
324 /* Update bulletin board size with response from PF */
325 p_iov->bulletin.size = resp->bulletin_size;
328 p_hwfn->p_dev->type = resp->pfdev_info.dev_type;
329 p_hwfn->p_dev->chip_rev = resp->pfdev_info.chip_rev;
331 DP_INFO(p_hwfn, "Chip details - %s%d\n",
332 ECORE_IS_BB(p_hwfn->p_dev) ? "BB" : "AH",
333 CHIP_REV_IS_A0(p_hwfn->p_dev) ? 0 : 1);
335 p_hwfn->p_dev->chip_num = pfdev_info->chip_num & 0xffff;
337 /* Learn of the possibility of CMT */
338 if (IS_LEAD_HWFN(p_hwfn)) {
339 if (resp->pfdev_info.capabilities & PFVF_ACQUIRE_CAP_100G) {
340 DP_INFO(p_hwfn, "100g VF\n");
341 p_hwfn->p_dev->num_hwfns = 2;
346 if ((~p_iov->b_pre_fp_hsi &
347 ETH_HSI_VER_MINOR) &&
348 (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR))
350 "PF is using older fastpath HSI;"
351 " %02x.%02x is configured\n",
353 resp->pfdev_info.minor_fp_hsi);
356 ecore_vf_pf_req_end(p_hwfn, rc);
361 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn)
363 struct ecore_vf_iov *p_iov;
366 /* Set number of hwfns - might be overridden once leading hwfn learns
367 * actual configuration from PF.
369 if (IS_LEAD_HWFN(p_hwfn))
370 p_hwfn->p_dev->num_hwfns = 1;
372 /* Set the doorbell bar. Assumption: regview is set */
373 p_hwfn->doorbells = (u8 OSAL_IOMEM *)p_hwfn->regview +
374 PXP_VF_BAR0_START_DQ;
376 reg = PXP_VF_BAR0_ME_OPAQUE_ADDRESS;
377 p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn, reg);
379 reg = PXP_VF_BAR0_ME_CONCRETE_ADDRESS;
380 p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn, reg);
382 /* Allocate vf sriov info */
383 p_iov = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL, sizeof(*p_iov));
385 DP_NOTICE(p_hwfn, true,
386 "Failed to allocate `struct ecore_sriov'\n");
390 OSAL_MEMSET(p_iov, 0, sizeof(*p_iov));
392 /* Allocate vf2pf msg */
393 p_iov->vf2pf_request = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
398 if (!p_iov->vf2pf_request) {
399 DP_NOTICE(p_hwfn, true,
400 "Failed to allocate `vf2pf_request' DMA memory\n");
404 p_iov->pf2vf_reply = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
407 sizeof(union pfvf_tlvs));
408 if (!p_iov->pf2vf_reply) {
409 DP_NOTICE(p_hwfn, true,
410 "Failed to allocate `pf2vf_reply' DMA memory\n");
411 goto free_vf2pf_request;
414 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
415 "VF's Request mailbox [%p virt 0x%lx phys], "
416 "Response mailbox [%p virt 0x%lx phys]\n",
417 p_iov->vf2pf_request,
418 (unsigned long)p_iov->vf2pf_request_phys,
420 (unsigned long)p_iov->pf2vf_reply_phys);
422 /* Allocate Bulletin board */
423 p_iov->bulletin.size = sizeof(struct ecore_bulletin_content);
424 p_iov->bulletin.p_virt = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
429 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
430 "VF's bulletin Board [%p virt 0x%lx phys 0x%08x bytes]\n",
431 p_iov->bulletin.p_virt, (unsigned long)p_iov->bulletin.phys,
432 p_iov->bulletin.size);
434 OSAL_MUTEX_ALLOC(p_hwfn, &p_iov->mutex);
435 OSAL_MUTEX_INIT(&p_iov->mutex);
437 p_hwfn->vf_iov_info = p_iov;
439 p_hwfn->hw_info.personality = ECORE_PCI_ETH;
441 return ecore_vf_pf_acquire(p_hwfn);
444 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_iov->vf2pf_request,
445 p_iov->vf2pf_request_phys,
446 sizeof(union vfpf_tlvs));
448 OSAL_FREE(p_hwfn->p_dev, p_iov);
453 #define TSTORM_QZONE_START PXP_VF_BAR0_START_SDM_ZONE_A
454 #define MSTORM_QZONE_START(dev) (TSTORM_QZONE_START + \
455 (TSTORM_QZONE_SIZE * NUM_OF_L2_QUEUES(dev)))
457 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
462 dma_addr_t bd_chain_phys_addr,
463 dma_addr_t cqe_pbl_addr,
465 void OSAL_IOMEM **pp_prod)
467 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
468 struct pfvf_start_queue_resp_tlv *resp;
469 struct vfpf_start_rxq_tlv *req;
470 enum _ecore_status_t rc;
472 /* clear mailbox and prep first tlv */
473 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_RXQ, sizeof(*req));
475 req->rx_qid = rx_qid;
476 req->cqe_pbl_addr = cqe_pbl_addr;
477 req->cqe_pbl_size = cqe_pbl_size;
478 req->rxq_addr = bd_chain_phys_addr;
480 req->sb_index = sb_index;
481 req->bd_max_bytes = bd_max_bytes;
482 req->stat_id = -1; /* Keep initialized, for future compatibility */
484 /* If PF is legacy, we'll need to calculate producers ourselves
485 * as well as clean them.
487 if (pp_prod && p_iov->b_pre_fp_hsi) {
488 u8 hw_qid = p_iov->acquire_resp.resc.hw_qid[rx_qid];
489 u32 init_prod_val = 0;
491 *pp_prod = (u8 OSAL_IOMEM *)p_hwfn->regview +
492 MSTORM_QZONE_START(p_hwfn->p_dev) +
493 (hw_qid) * MSTORM_QZONE_SIZE;
495 /* Init the rcq, rx bd and rx sge (if valid) producers to 0 */
496 __internal_ram_wr(p_hwfn, *pp_prod, sizeof(u32),
497 (u32 *)(&init_prod_val));
500 /* add list termination tlv */
501 ecore_add_tlv(p_hwfn, &p_iov->offset,
502 CHANNEL_TLV_LIST_END,
503 sizeof(struct channel_list_end_tlv));
505 resp = &p_iov->pf2vf_reply->queue_start;
506 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
510 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
515 /* Learn the address of the producer from the response */
516 if (pp_prod && !p_iov->b_pre_fp_hsi) {
517 u32 init_prod_val = 0;
519 *pp_prod = (u8 OSAL_IOMEM *)p_hwfn->regview + resp->offset;
520 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
521 "Rxq[0x%02x]: producer at %p [offset 0x%08x]\n",
522 rx_qid, *pp_prod, resp->offset);
524 /* Init the rcq, rx bd and rx sge (if valid) producers to 0.
525 * It was actually the PF's responsibility, but since some
526 * old PFs might fail to do so, we do this as well.
528 OSAL_BUILD_BUG_ON(ETH_HSI_VER_MAJOR != 3);
529 __internal_ram_wr(p_hwfn, *pp_prod, sizeof(u32),
530 (u32 *)&init_prod_val);
534 ecore_vf_pf_req_end(p_hwfn, rc);
539 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
540 u16 rx_qid, bool cqe_completion)
542 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
543 struct vfpf_stop_rxqs_tlv *req;
544 struct pfvf_def_resp_tlv *resp;
545 enum _ecore_status_t rc;
547 /* clear mailbox and prep first tlv */
548 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_RXQS, sizeof(*req));
550 req->rx_qid = rx_qid;
552 req->cqe_completion = cqe_completion;
554 /* add list termination tlv */
555 ecore_add_tlv(p_hwfn, &p_iov->offset,
556 CHANNEL_TLV_LIST_END,
557 sizeof(struct channel_list_end_tlv));
559 resp = &p_iov->pf2vf_reply->default_resp;
560 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
564 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
570 ecore_vf_pf_req_end(p_hwfn, rc);
575 enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
581 void OSAL_IOMEM **pp_doorbell)
583 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
584 struct pfvf_start_queue_resp_tlv *resp;
585 struct vfpf_start_txq_tlv *req;
586 enum _ecore_status_t rc;
588 /* clear mailbox and prep first tlv */
589 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_TXQ, sizeof(*req));
591 req->tx_qid = tx_queue_id;
594 req->pbl_addr = pbl_addr;
595 req->pbl_size = pbl_size;
597 req->sb_index = sb_index;
599 /* add list termination tlv */
600 ecore_add_tlv(p_hwfn, &p_iov->offset,
601 CHANNEL_TLV_LIST_END,
602 sizeof(struct channel_list_end_tlv));
604 resp = &p_iov->pf2vf_reply->queue_start;
605 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
609 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
615 /* Modern PFs provide the actual offsets, while legacy
616 * provided only the queue id.
618 if (!p_iov->b_pre_fp_hsi) {
619 *pp_doorbell = (u8 OSAL_IOMEM *)p_hwfn->doorbells +
622 u8 cid = p_iov->acquire_resp.resc.cid[tx_queue_id];
624 *pp_doorbell = (u8 OSAL_IOMEM *)p_hwfn->doorbells +
625 DB_ADDR_VF(cid, DQ_DEMS_LEGACY);
628 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
629 "Txq[0x%02x]: doorbell at %p [offset 0x%08x]\n",
630 tx_queue_id, *pp_doorbell, resp->offset);
634 ecore_vf_pf_req_end(p_hwfn, rc);
639 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, u16 tx_qid)
641 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
642 struct vfpf_stop_txqs_tlv *req;
643 struct pfvf_def_resp_tlv *resp;
644 enum _ecore_status_t rc;
646 /* clear mailbox and prep first tlv */
647 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_TXQS, sizeof(*req));
649 req->tx_qid = tx_qid;
652 /* add list termination tlv */
653 ecore_add_tlv(p_hwfn, &p_iov->offset,
654 CHANNEL_TLV_LIST_END,
655 sizeof(struct channel_list_end_tlv));
657 resp = &p_iov->pf2vf_reply->default_resp;
658 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
662 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
668 ecore_vf_pf_req_end(p_hwfn, rc);
673 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
676 u8 comp_cqe_flg, u8 comp_event_flg)
678 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
679 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
680 struct vfpf_update_rxq_tlv *req;
681 enum _ecore_status_t rc;
683 /* clear mailbox and prep first tlv */
684 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UPDATE_RXQ, sizeof(*req));
686 req->rx_qid = rx_queue_id;
687 req->num_rxqs = num_rxqs;
690 req->flags |= VFPF_RXQ_UPD_COMPLETE_CQE_FLAG;
692 req->flags |= VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG;
694 /* add list termination tlv */
695 ecore_add_tlv(p_hwfn, &p_iov->offset,
696 CHANNEL_TLV_LIST_END,
697 sizeof(struct channel_list_end_tlv));
699 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
703 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
709 ecore_vf_pf_req_end(p_hwfn, rc);
715 ecore_vf_pf_vport_start(struct ecore_hwfn *p_hwfn, u8 vport_id,
716 u16 mtu, u8 inner_vlan_removal,
717 enum ecore_tpa_mode tpa_mode, u8 max_buffers_per_cqe,
720 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
721 struct vfpf_vport_start_tlv *req;
722 struct pfvf_def_resp_tlv *resp;
723 enum _ecore_status_t rc;
726 /* clear mailbox and prep first tlv */
727 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_START, sizeof(*req));
730 req->vport_id = vport_id;
731 req->inner_vlan_removal = inner_vlan_removal;
732 req->tpa_mode = tpa_mode;
733 req->max_buffers_per_cqe = max_buffers_per_cqe;
734 req->only_untagged = only_untagged;
737 for (i = 0; i < p_hwfn->vf_iov_info->acquire_resp.resc.num_sbs; i++)
738 if (p_hwfn->sbs_info[i])
739 req->sb_addr[i] = p_hwfn->sbs_info[i]->sb_phys;
741 /* add list termination tlv */
742 ecore_add_tlv(p_hwfn, &p_iov->offset,
743 CHANNEL_TLV_LIST_END,
744 sizeof(struct channel_list_end_tlv));
746 resp = &p_iov->pf2vf_reply->default_resp;
747 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
751 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
757 ecore_vf_pf_req_end(p_hwfn, rc);
762 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn)
764 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
765 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
766 enum _ecore_status_t rc;
768 /* clear mailbox and prep first tlv */
769 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_TEARDOWN,
770 sizeof(struct vfpf_first_tlv));
772 /* add list termination tlv */
773 ecore_add_tlv(p_hwfn, &p_iov->offset,
774 CHANNEL_TLV_LIST_END,
775 sizeof(struct channel_list_end_tlv));
777 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
781 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
787 ecore_vf_pf_req_end(p_hwfn, rc);
793 ecore_vf_handle_vp_update_is_needed(struct ecore_hwfn *p_hwfn,
794 struct ecore_sp_vport_update_params *p_data,
798 case CHANNEL_TLV_VPORT_UPDATE_ACTIVATE:
799 return !!(p_data->update_vport_active_rx_flg ||
800 p_data->update_vport_active_tx_flg);
801 case CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH:
803 /* FPGA doesn't have PVFC and so can't support tx-switching */
804 return !!(p_data->update_tx_switching_flg &&
805 !CHIP_REV_IS_FPGA(p_hwfn->p_dev));
807 return !!p_data->update_tx_switching_flg;
809 case CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP:
810 return !!p_data->update_inner_vlan_removal_flg;
811 case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN:
812 return !!p_data->update_accept_any_vlan_flg;
813 case CHANNEL_TLV_VPORT_UPDATE_MCAST:
814 return !!p_data->update_approx_mcast_flg;
815 case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM:
816 return !!(p_data->accept_flags.update_rx_mode_config ||
817 p_data->accept_flags.update_tx_mode_config);
818 case CHANNEL_TLV_VPORT_UPDATE_RSS:
819 return !!p_data->rss_params;
820 case CHANNEL_TLV_VPORT_UPDATE_SGE_TPA:
821 return !!p_data->sge_tpa_params;
823 DP_INFO(p_hwfn, "Unexpected vport-update TLV[%d] %s\n",
824 tlv, ecore_channel_tlvs_string[tlv]);
830 ecore_vf_handle_vp_update_tlvs_resp(struct ecore_hwfn *p_hwfn,
831 struct ecore_sp_vport_update_params *p_data)
833 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
834 struct pfvf_def_resp_tlv *p_resp;
837 for (tlv = CHANNEL_TLV_VPORT_UPDATE_ACTIVATE;
838 tlv < CHANNEL_TLV_VPORT_UPDATE_MAX;
840 if (!ecore_vf_handle_vp_update_is_needed(p_hwfn, p_data, tlv))
843 p_resp = (struct pfvf_def_resp_tlv *)
844 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
845 if (p_resp && p_resp->hdr.status)
846 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
847 "TLV[%d] type %s Configuration %s\n",
848 tlv, ecore_channel_tlvs_string[tlv],
849 (p_resp && p_resp->hdr.status) ? "succeeded"
855 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
856 struct ecore_sp_vport_update_params *p_params)
858 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
859 struct vfpf_vport_update_tlv *req;
860 struct pfvf_def_resp_tlv *resp;
861 u8 update_rx, update_tx;
864 enum _ecore_status_t rc;
866 resp = &p_iov->pf2vf_reply->default_resp;
867 resp_size = sizeof(*resp);
869 update_rx = p_params->update_vport_active_rx_flg;
870 update_tx = p_params->update_vport_active_tx_flg;
872 /* clear mailbox and prep header tlv */
873 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_UPDATE, sizeof(*req));
875 /* Prepare extended tlvs */
876 if (update_rx || update_tx) {
877 struct vfpf_vport_update_activate_tlv *p_act_tlv;
879 size = sizeof(struct vfpf_vport_update_activate_tlv);
880 p_act_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
881 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
883 resp_size += sizeof(struct pfvf_def_resp_tlv);
886 p_act_tlv->update_rx = update_rx;
887 p_act_tlv->active_rx = p_params->vport_active_rx_flg;
891 p_act_tlv->update_tx = update_tx;
892 p_act_tlv->active_tx = p_params->vport_active_tx_flg;
896 if (p_params->update_inner_vlan_removal_flg) {
897 struct vfpf_vport_update_vlan_strip_tlv *p_vlan_tlv;
899 size = sizeof(struct vfpf_vport_update_vlan_strip_tlv);
900 p_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
901 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
903 resp_size += sizeof(struct pfvf_def_resp_tlv);
905 p_vlan_tlv->remove_vlan = p_params->inner_vlan_removal_flg;
908 if (p_params->update_tx_switching_flg) {
909 struct vfpf_vport_update_tx_switch_tlv *p_tx_switch_tlv;
911 size = sizeof(struct vfpf_vport_update_tx_switch_tlv);
912 tlv = CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH;
913 p_tx_switch_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
915 resp_size += sizeof(struct pfvf_def_resp_tlv);
917 p_tx_switch_tlv->tx_switching = p_params->tx_switching_flg;
920 if (p_params->update_approx_mcast_flg) {
921 struct vfpf_vport_update_mcast_bin_tlv *p_mcast_tlv;
923 size = sizeof(struct vfpf_vport_update_mcast_bin_tlv);
924 p_mcast_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
925 CHANNEL_TLV_VPORT_UPDATE_MCAST,
927 resp_size += sizeof(struct pfvf_def_resp_tlv);
929 OSAL_MEMCPY(p_mcast_tlv->bins, p_params->bins,
930 sizeof(unsigned long) *
931 ETH_MULTICAST_MAC_BINS_IN_REGS);
934 update_rx = p_params->accept_flags.update_rx_mode_config;
935 update_tx = p_params->accept_flags.update_tx_mode_config;
937 if (update_rx || update_tx) {
938 struct vfpf_vport_update_accept_param_tlv *p_accept_tlv;
940 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM;
941 size = sizeof(struct vfpf_vport_update_accept_param_tlv);
942 p_accept_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset, tlv, size);
943 resp_size += sizeof(struct pfvf_def_resp_tlv);
946 p_accept_tlv->update_rx_mode = update_rx;
947 p_accept_tlv->rx_accept_filter =
948 p_params->accept_flags.rx_accept_filter;
952 p_accept_tlv->update_tx_mode = update_tx;
953 p_accept_tlv->tx_accept_filter =
954 p_params->accept_flags.tx_accept_filter;
958 if (p_params->rss_params) {
959 struct ecore_rss_params *rss_params = p_params->rss_params;
960 struct vfpf_vport_update_rss_tlv *p_rss_tlv;
962 size = sizeof(struct vfpf_vport_update_rss_tlv);
963 p_rss_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
964 CHANNEL_TLV_VPORT_UPDATE_RSS, size);
965 resp_size += sizeof(struct pfvf_def_resp_tlv);
967 if (rss_params->update_rss_config)
968 p_rss_tlv->update_rss_flags |=
969 VFPF_UPDATE_RSS_CONFIG_FLAG;
970 if (rss_params->update_rss_capabilities)
971 p_rss_tlv->update_rss_flags |=
972 VFPF_UPDATE_RSS_CAPS_FLAG;
973 if (rss_params->update_rss_ind_table)
974 p_rss_tlv->update_rss_flags |=
975 VFPF_UPDATE_RSS_IND_TABLE_FLAG;
976 if (rss_params->update_rss_key)
977 p_rss_tlv->update_rss_flags |= VFPF_UPDATE_RSS_KEY_FLAG;
979 p_rss_tlv->rss_enable = rss_params->rss_enable;
980 p_rss_tlv->rss_caps = rss_params->rss_caps;
981 p_rss_tlv->rss_table_size_log = rss_params->rss_table_size_log;
982 OSAL_MEMCPY(p_rss_tlv->rss_ind_table, rss_params->rss_ind_table,
983 sizeof(rss_params->rss_ind_table));
984 OSAL_MEMCPY(p_rss_tlv->rss_key, rss_params->rss_key,
985 sizeof(rss_params->rss_key));
988 if (p_params->update_accept_any_vlan_flg) {
989 struct vfpf_vport_update_accept_any_vlan_tlv *p_any_vlan_tlv;
991 size = sizeof(struct vfpf_vport_update_accept_any_vlan_tlv);
992 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN;
993 p_any_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
996 resp_size += sizeof(struct pfvf_def_resp_tlv);
997 p_any_vlan_tlv->accept_any_vlan = p_params->accept_any_vlan;
998 p_any_vlan_tlv->update_accept_any_vlan_flg =
999 p_params->update_accept_any_vlan_flg;
1002 if (p_params->sge_tpa_params) {
1003 struct ecore_sge_tpa_params *sge_tpa_params;
1004 struct vfpf_vport_update_sge_tpa_tlv *p_sge_tpa_tlv;
1006 sge_tpa_params = p_params->sge_tpa_params;
1007 size = sizeof(struct vfpf_vport_update_sge_tpa_tlv);
1008 p_sge_tpa_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
1009 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
1011 resp_size += sizeof(struct pfvf_def_resp_tlv);
1013 if (sge_tpa_params->update_tpa_en_flg)
1014 p_sge_tpa_tlv->update_sge_tpa_flags |=
1015 VFPF_UPDATE_TPA_EN_FLAG;
1016 if (sge_tpa_params->update_tpa_param_flg)
1017 p_sge_tpa_tlv->update_sge_tpa_flags |=
1018 VFPF_UPDATE_TPA_PARAM_FLAG;
1020 if (sge_tpa_params->tpa_ipv4_en_flg)
1021 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV4_EN_FLAG;
1022 if (sge_tpa_params->tpa_ipv6_en_flg)
1023 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV6_EN_FLAG;
1024 if (sge_tpa_params->tpa_pkt_split_flg)
1025 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_PKT_SPLIT_FLAG;
1026 if (sge_tpa_params->tpa_hdr_data_split_flg)
1027 p_sge_tpa_tlv->sge_tpa_flags |=
1028 VFPF_TPA_HDR_DATA_SPLIT_FLAG;
1029 if (sge_tpa_params->tpa_gro_consistent_flg)
1030 p_sge_tpa_tlv->sge_tpa_flags |=
1031 VFPF_TPA_GRO_CONSIST_FLAG;
1033 p_sge_tpa_tlv->tpa_max_aggs_num =
1034 sge_tpa_params->tpa_max_aggs_num;
1035 p_sge_tpa_tlv->tpa_max_size = sge_tpa_params->tpa_max_size;
1036 p_sge_tpa_tlv->tpa_min_size_to_start =
1037 sge_tpa_params->tpa_min_size_to_start;
1038 p_sge_tpa_tlv->tpa_min_size_to_cont =
1039 sge_tpa_params->tpa_min_size_to_cont;
1041 p_sge_tpa_tlv->max_buffers_per_cqe =
1042 sge_tpa_params->max_buffers_per_cqe;
1045 /* add list termination tlv */
1046 ecore_add_tlv(p_hwfn, &p_iov->offset,
1047 CHANNEL_TLV_LIST_END,
1048 sizeof(struct channel_list_end_tlv));
1050 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, resp_size);
1054 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1059 ecore_vf_handle_vp_update_tlvs_resp(p_hwfn, p_params);
1062 ecore_vf_pf_req_end(p_hwfn, rc);
1067 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn)
1069 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1070 struct pfvf_def_resp_tlv *resp;
1071 struct vfpf_first_tlv *req;
1072 enum _ecore_status_t rc;
1074 /* clear mailbox and prep first tlv */
1075 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_CLOSE, sizeof(*req));
1077 /* add list termination tlv */
1078 ecore_add_tlv(p_hwfn, &p_iov->offset,
1079 CHANNEL_TLV_LIST_END,
1080 sizeof(struct channel_list_end_tlv));
1082 resp = &p_iov->pf2vf_reply->default_resp;
1083 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1087 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1092 p_hwfn->b_int_enabled = 0;
1095 ecore_vf_pf_req_end(p_hwfn, rc);
1100 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn)
1102 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1103 struct pfvf_def_resp_tlv *resp;
1104 struct vfpf_first_tlv *req;
1105 enum _ecore_status_t rc;
1108 /* clear mailbox and prep first tlv */
1109 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_RELEASE, sizeof(*req));
1111 /* add list termination tlv */
1112 ecore_add_tlv(p_hwfn, &p_iov->offset,
1113 CHANNEL_TLV_LIST_END,
1114 sizeof(struct channel_list_end_tlv));
1116 resp = &p_iov->pf2vf_reply->default_resp;
1117 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1119 if (rc == ECORE_SUCCESS && resp->hdr.status != PFVF_STATUS_SUCCESS)
1122 ecore_vf_pf_req_end(p_hwfn, rc);
1124 p_hwfn->b_int_enabled = 0;
1126 if (p_iov->vf2pf_request)
1127 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1128 p_iov->vf2pf_request,
1129 p_iov->vf2pf_request_phys,
1130 sizeof(union vfpf_tlvs));
1131 if (p_iov->pf2vf_reply)
1132 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1134 p_iov->pf2vf_reply_phys,
1135 sizeof(union pfvf_tlvs));
1137 if (p_iov->bulletin.p_virt) {
1138 size = sizeof(struct ecore_bulletin_content);
1139 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1140 p_iov->bulletin.p_virt,
1141 p_iov->bulletin.phys, size);
1144 OSAL_FREE(p_hwfn->p_dev, p_hwfn->vf_iov_info);
1145 p_hwfn->vf_iov_info = OSAL_NULL;
1150 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
1151 struct ecore_filter_mcast *p_filter_cmd)
1153 struct ecore_sp_vport_update_params sp_params;
1156 OSAL_MEMSET(&sp_params, 0, sizeof(sp_params));
1157 sp_params.update_approx_mcast_flg = 1;
1159 if (p_filter_cmd->opcode == ECORE_FILTER_ADD) {
1160 for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) {
1163 bit = ecore_mcast_bin_from_mac(p_filter_cmd->mac[i]);
1164 OSAL_SET_BIT(bit, sp_params.bins);
1168 ecore_vf_pf_vport_update(p_hwfn, &sp_params);
1171 enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn *p_hwfn,
1172 struct ecore_filter_ucast
1175 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1176 struct vfpf_ucast_filter_tlv *req;
1177 struct pfvf_def_resp_tlv *resp;
1178 enum _ecore_status_t rc;
1181 if (p_ucast->opcode == ECORE_FILTER_MOVE) {
1182 DP_NOTICE(p_hwfn, true,
1183 "VFs don't support Moving of filters\n");
1187 /* clear mailbox and prep first tlv */
1188 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UCAST_FILTER, sizeof(*req));
1189 req->opcode = (u8)p_ucast->opcode;
1190 req->type = (u8)p_ucast->type;
1191 OSAL_MEMCPY(req->mac, p_ucast->mac, ETH_ALEN);
1192 req->vlan = p_ucast->vlan;
1194 /* add list termination tlv */
1195 ecore_add_tlv(p_hwfn, &p_iov->offset,
1196 CHANNEL_TLV_LIST_END,
1197 sizeof(struct channel_list_end_tlv));
1199 resp = &p_iov->pf2vf_reply->default_resp;
1200 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1204 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1210 ecore_vf_pf_req_end(p_hwfn, rc);
1215 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn)
1217 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1218 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
1219 enum _ecore_status_t rc;
1221 /* clear mailbox and prep first tlv */
1222 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_INT_CLEANUP,
1223 sizeof(struct vfpf_first_tlv));
1225 /* add list termination tlv */
1226 ecore_add_tlv(p_hwfn, &p_iov->offset,
1227 CHANNEL_TLV_LIST_END,
1228 sizeof(struct channel_list_end_tlv));
1230 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1234 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1240 ecore_vf_pf_req_end(p_hwfn, rc);
1245 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
1248 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1251 DP_NOTICE(p_hwfn, true, "vf_sriov_info isn't initialized\n");
1255 return p_iov->acquire_resp.resc.hw_sbs[sb_id].hw_sb_id;
1258 enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn,
1261 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1262 struct ecore_bulletin_content shadow;
1265 crc_size = sizeof(p_iov->bulletin.p_virt->crc);
1268 /* Need to guarantee PF is not in the middle of writing it */
1269 OSAL_MEMCPY(&shadow, p_iov->bulletin.p_virt, p_iov->bulletin.size);
1271 /* If version did not update, no need to do anything */
1272 if (shadow.version == p_iov->bulletin_shadow.version)
1273 return ECORE_SUCCESS;
1275 /* Verify the bulletin we see is valid */
1276 crc = ecore_crc32(0, (u8 *)&shadow + crc_size,
1277 p_iov->bulletin.size - crc_size);
1278 if (crc != shadow.crc)
1281 /* Set the shadow bulletin and process it */
1282 OSAL_MEMCPY(&p_iov->bulletin_shadow, &shadow, p_iov->bulletin.size);
1284 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
1285 "Read a bulletin update %08x\n", shadow.version);
1289 return ECORE_SUCCESS;
1292 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1293 struct ecore_mcp_link_params *p_params,
1294 struct ecore_bulletin_content *p_bulletin)
1296 OSAL_MEMSET(p_params, 0, sizeof(*p_params));
1298 p_params->speed.autoneg = p_bulletin->req_autoneg;
1299 p_params->speed.advertised_speeds = p_bulletin->req_adv_speed;
1300 p_params->speed.forced_speed = p_bulletin->req_forced_speed;
1301 p_params->pause.autoneg = p_bulletin->req_autoneg_pause;
1302 p_params->pause.forced_rx = p_bulletin->req_forced_rx;
1303 p_params->pause.forced_tx = p_bulletin->req_forced_tx;
1304 p_params->loopback_mode = p_bulletin->req_loopback;
1307 void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1308 struct ecore_mcp_link_params *params)
1310 __ecore_vf_get_link_params(p_hwfn, params,
1311 &p_hwfn->vf_iov_info->bulletin_shadow);
1314 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1315 struct ecore_mcp_link_state *p_link,
1316 struct ecore_bulletin_content *p_bulletin)
1318 OSAL_MEMSET(p_link, 0, sizeof(*p_link));
1320 p_link->link_up = p_bulletin->link_up;
1321 p_link->speed = p_bulletin->speed;
1322 p_link->full_duplex = p_bulletin->full_duplex;
1323 p_link->an = p_bulletin->autoneg;
1324 p_link->an_complete = p_bulletin->autoneg_complete;
1325 p_link->parallel_detection = p_bulletin->parallel_detection;
1326 p_link->pfc_enabled = p_bulletin->pfc_enabled;
1327 p_link->partner_adv_speed = p_bulletin->partner_adv_speed;
1328 p_link->partner_tx_flow_ctrl_en = p_bulletin->partner_tx_flow_ctrl_en;
1329 p_link->partner_rx_flow_ctrl_en = p_bulletin->partner_rx_flow_ctrl_en;
1330 p_link->partner_adv_pause = p_bulletin->partner_adv_pause;
1331 p_link->sfp_tx_fault = p_bulletin->sfp_tx_fault;
1334 void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1335 struct ecore_mcp_link_state *link)
1337 __ecore_vf_get_link_state(p_hwfn, link,
1338 &p_hwfn->vf_iov_info->bulletin_shadow);
1341 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1342 struct ecore_mcp_link_capabilities *p_link_caps,
1343 struct ecore_bulletin_content *p_bulletin)
1345 OSAL_MEMSET(p_link_caps, 0, sizeof(*p_link_caps));
1346 p_link_caps->speed_capabilities = p_bulletin->capability_speed;
1349 void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1350 struct ecore_mcp_link_capabilities *p_link_caps)
1352 __ecore_vf_get_link_caps(p_hwfn, p_link_caps,
1353 &p_hwfn->vf_iov_info->bulletin_shadow);
1356 void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, u8 *num_rxqs)
1358 *num_rxqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_rxqs;
1361 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, u8 *port_mac)
1363 OSAL_MEMCPY(port_mac,
1364 p_hwfn->vf_iov_info->acquire_resp.pfdev_info.port_mac,
1368 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn,
1369 u8 *num_vlan_filters)
1371 struct ecore_vf_iov *p_vf;
1373 p_vf = p_hwfn->vf_iov_info;
1374 *num_vlan_filters = p_vf->acquire_resp.resc.num_vlan_filters;
1378 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn,
1381 struct ecore_vf_iov *p_vf;
1383 p_vf = p_hwfn->vf_iov_info;
1384 *num_mac = p_vf->acquire_resp.resc.num_mac_filters;
1387 void ecore_vf_get_num_sbs(struct ecore_hwfn *p_hwfn,
1390 struct ecore_vf_iov *p_vf;
1392 p_vf = p_hwfn->vf_iov_info;
1393 *num_sbs = (u32)p_vf->acquire_resp.resc.num_sbs;
1396 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac)
1398 struct ecore_bulletin_content *bulletin;
1400 bulletin = &p_hwfn->vf_iov_info->bulletin_shadow;
1401 if (!(bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)))
1404 /* Forbid VF from changing a MAC enforced by PF */
1405 if (OSAL_MEMCMP(bulletin->mac, mac, ETH_ALEN))
1411 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
1414 struct ecore_bulletin_content *bulletin;
1416 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1418 if (bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)) {
1421 } else if (bulletin->valid_bitmap & (1 << VFPF_BULLETIN_MAC_ADDR)) {
1428 OSAL_MEMCPY(dst_mac, bulletin->mac, ETH_ALEN);
1433 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid)
1435 struct ecore_bulletin_content *bulletin;
1437 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1439 if (!(bulletin->valid_bitmap & (1 << VLAN_ADDR_FORCED)))
1443 *dst_pvid = bulletin->pvid;
1448 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn)
1450 return p_hwfn->vf_iov_info->b_pre_fp_hsi;
1453 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn,
1454 u16 *fw_major, u16 *fw_minor, u16 *fw_rev,
1457 struct pf_vf_pfdev_info *info;
1459 info = &p_hwfn->vf_iov_info->acquire_resp.pfdev_info;
1461 *fw_major = info->fw_major;
1462 *fw_minor = info->fw_minor;
1463 *fw_rev = info->fw_rev;
1464 *fw_eng = info->fw_eng;