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 int ecore_send_msg2pf(struct ecore_hwfn *p_hwfn,
69 u8 *done, u32 resp_size)
71 union vfpf_tlvs *p_req = p_hwfn->vf_iov_info->vf2pf_request;
72 struct ustorm_trigger_vf_zone trigger;
73 struct ustorm_vf_zone *zone_data;
74 int rc = ECORE_SUCCESS, time = 100;
76 zone_data = (struct ustorm_vf_zone *)PXP_VF_BAR0_START_USDM_ZONE_B;
78 /* output tlvs list */
79 ecore_dp_tlv_list(p_hwfn, p_req);
81 /* need to add the END TLV to the message size */
82 resp_size += sizeof(struct channel_list_end_tlv);
84 if (!p_hwfn->p_dev->b_hw_channel) {
85 rc = OSAL_VF_SEND_MSG2PF(p_hwfn->p_dev,
88 p_hwfn->vf_iov_info->pf2vf_reply,
89 sizeof(union vfpf_tlvs), resp_size);
90 /* TODO - no prints about message ? */
94 /* Send TLVs over HW channel */
95 OSAL_MEMSET(&trigger, 0, sizeof(struct ustorm_trigger_vf_zone));
96 trigger.vf_pf_msg_valid = 1;
98 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
99 "VF -> PF [%02x] message: [%08x, %08x] --> %p,"
101 GET_FIELD(p_hwfn->hw_info.concrete_fid,
102 PXP_CONCRETE_FID_PFID),
103 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys),
104 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys),
105 &zone_data->non_trigger.vf_pf_msg_addr,
106 *((u32 *)&trigger), &zone_data->trigger);
109 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.lo,
110 U64_LO(p_hwfn->vf_iov_info->vf2pf_request_phys));
113 (osal_uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.hi,
114 U64_HI(p_hwfn->vf_iov_info->vf2pf_request_phys));
116 /* The message data must be written first, to prevent trigger before
119 OSAL_WMB(p_hwfn->p_dev);
121 REG_WR(p_hwfn, (osal_uintptr_t)&zone_data->trigger,
124 /* When PF would be done with the response, it would write back to the
125 * `done' address. Poll until then.
127 while ((!*done) && time) {
133 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
134 "VF <-- PF Timeout [Type %d]\n",
135 p_req->first_tlv.tl.type);
139 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
140 "PF response: %d [Type %d]\n",
141 *done, p_req->first_tlv.tl.type);
147 #define VF_ACQUIRE_THRESH 3
148 static void ecore_vf_pf_acquire_reduce_resc(struct ecore_hwfn *p_hwfn,
149 struct vf_pf_resc_request *p_req,
150 struct pf_vf_resc *p_resp)
152 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
153 "PF unwilling to fullill resource request: rxq [%02x/%02x]"
154 " txq [%02x/%02x] sbs [%02x/%02x] mac [%02x/%02x]"
155 " vlan [%02x/%02x] mc [%02x/%02x]."
156 " Try PF recommended amount\n",
157 p_req->num_rxqs, p_resp->num_rxqs,
158 p_req->num_rxqs, p_resp->num_txqs,
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);
164 /* humble our request */
165 p_req->num_txqs = p_resp->num_txqs;
166 p_req->num_rxqs = p_resp->num_rxqs;
167 p_req->num_sbs = p_resp->num_sbs;
168 p_req->num_mac_filters = p_resp->num_mac_filters;
169 p_req->num_vlan_filters = p_resp->num_vlan_filters;
170 p_req->num_mc_filters = p_resp->num_mc_filters;
173 static enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn)
175 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
176 struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
177 struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
178 struct ecore_vf_acquire_sw_info vf_sw_info;
179 struct vf_pf_resc_request *p_resc;
180 bool resources_acquired = false;
181 struct vfpf_acquire_tlv *req;
183 enum _ecore_status_t rc = ECORE_SUCCESS;
185 /* clear mailbox and prep first tlv */
186 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_ACQUIRE, sizeof(*req));
187 p_resc = &req->resc_request;
189 /* @@@ TBD: PF may not be ready bnx2x_get_vf_id... */
190 req->vfdev_info.opaque_fid = p_hwfn->hw_info.opaque_fid;
192 p_resc->num_rxqs = ECORE_MAX_VF_CHAINS_PER_PF;
193 p_resc->num_txqs = ECORE_MAX_VF_CHAINS_PER_PF;
194 p_resc->num_sbs = ECORE_MAX_VF_CHAINS_PER_PF;
195 p_resc->num_mac_filters = ECORE_ETH_VF_NUM_MAC_FILTERS;
196 p_resc->num_vlan_filters = ECORE_ETH_VF_NUM_VLAN_FILTERS;
198 OSAL_MEMSET(&vf_sw_info, 0, sizeof(vf_sw_info));
199 OSAL_VF_FILL_ACQUIRE_RESC_REQ(p_hwfn, &req->resc_request, &vf_sw_info);
201 req->vfdev_info.os_type = vf_sw_info.os_type;
202 req->vfdev_info.driver_version = vf_sw_info.driver_version;
203 req->vfdev_info.fw_major = FW_MAJOR_VERSION;
204 req->vfdev_info.fw_minor = FW_MINOR_VERSION;
205 req->vfdev_info.fw_revision = FW_REVISION_VERSION;
206 req->vfdev_info.fw_engineering = FW_ENGINEERING_VERSION;
207 req->vfdev_info.eth_fp_hsi_major = ETH_HSI_VER_MAJOR;
208 req->vfdev_info.eth_fp_hsi_minor = ETH_HSI_VER_MINOR;
210 /* Fill capability field with any non-deprecated config we support */
211 req->vfdev_info.capabilities |= VFPF_ACQUIRE_CAP_100G;
213 /* pf 2 vf bulletin board address */
214 req->bulletin_addr = p_iov->bulletin.phys;
215 req->bulletin_size = p_iov->bulletin.size;
217 /* add list termination tlv */
218 ecore_add_tlv(p_hwfn, &p_iov->offset,
219 CHANNEL_TLV_LIST_END,
220 sizeof(struct channel_list_end_tlv));
222 while (!resources_acquired) {
223 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
224 "attempting to acquire resources\n");
226 /* Clear response buffer, as this might be a re-send */
227 OSAL_MEMSET(p_iov->pf2vf_reply, 0,
228 sizeof(union pfvf_tlvs));
230 /* send acquire request */
231 rc = ecore_send_msg2pf(p_hwfn,
232 &resp->hdr.status, sizeof(*resp));
238 /* copy acquire response from buffer to p_hwfn */
239 OSAL_MEMCPY(&p_iov->acquire_resp,
240 resp, sizeof(p_iov->acquire_resp));
244 if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
245 /* PF agrees to allocate our resources */
246 if (!(resp->pfdev_info.capabilities &
247 PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE)) {
248 /* It's possible legacy PF mistakenly accepted;
249 * but we don't care - simply mark it as
250 * legacy and continue.
252 req->vfdev_info.capabilities |=
253 VFPF_ACQUIRE_CAP_PRE_FP_HSI;
255 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
256 "resources acquired\n");
257 resources_acquired = true;
258 } /* PF refuses to allocate our resources */
259 else if (resp->hdr.status == PFVF_STATUS_NO_RESOURCE &&
260 attempts < VF_ACQUIRE_THRESH) {
261 ecore_vf_pf_acquire_reduce_resc(p_hwfn, p_resc,
264 } else if (resp->hdr.status == PFVF_STATUS_NOT_SUPPORTED) {
265 if (pfdev_info->major_fp_hsi &&
266 (pfdev_info->major_fp_hsi != ETH_HSI_VER_MAJOR)) {
267 DP_NOTICE(p_hwfn, false,
268 "PF uses an incompatible fastpath HSI"
269 " %02x.%02x [VF requires %02x.%02x]."
270 " Please change to a VF driver using"
272 pfdev_info->major_fp_hsi,
273 pfdev_info->minor_fp_hsi,
274 ETH_HSI_VER_MAJOR, ETH_HSI_VER_MINOR,
275 pfdev_info->major_fp_hsi);
280 if (!pfdev_info->major_fp_hsi) {
281 if (req->vfdev_info.capabilities &
282 VFPF_ACQUIRE_CAP_PRE_FP_HSI) {
283 DP_NOTICE(p_hwfn, false,
284 "PF uses very old drivers."
285 " Please change to a VF"
286 " driver using no later than"
292 "PF is old - try re-acquire to"
293 " see if it supports FW-version"
295 req->vfdev_info.capabilities |=
296 VFPF_ACQUIRE_CAP_PRE_FP_HSI;
301 /* If PF/VF are using same Major, PF must have had
302 * it's reasons. Simply fail.
304 DP_NOTICE(p_hwfn, false,
305 "PF rejected acquisition by VF\n");
310 "PF returned err %d to VF acquisition request\n",
317 /* Mark the PF as legacy, if needed */
318 if (req->vfdev_info.capabilities &
319 VFPF_ACQUIRE_CAP_PRE_FP_HSI)
320 p_iov->b_pre_fp_hsi = true;
322 rc = OSAL_VF_UPDATE_ACQUIRE_RESC_RESP(p_hwfn, &resp->resc);
324 DP_NOTICE(p_hwfn, true,
325 "VF_UPDATE_ACQUIRE_RESC_RESP Failed:"
332 /* Update bulletin board size with response from PF */
333 p_iov->bulletin.size = resp->bulletin_size;
336 p_hwfn->p_dev->type = resp->pfdev_info.dev_type;
337 p_hwfn->p_dev->chip_rev = resp->pfdev_info.chip_rev;
339 DP_INFO(p_hwfn, "Chip details - %s%d\n",
340 ECORE_IS_BB(p_hwfn->p_dev) ? "BB" : "AH",
341 CHIP_REV_IS_A0(p_hwfn->p_dev) ? 0 : 1);
343 p_hwfn->p_dev->chip_num = pfdev_info->chip_num & 0xffff;
345 /* Learn of the possibility of CMT */
346 if (IS_LEAD_HWFN(p_hwfn)) {
347 if (resp->pfdev_info.capabilities & PFVF_ACQUIRE_CAP_100G) {
348 DP_INFO(p_hwfn, "100g VF\n");
349 p_hwfn->p_dev->num_hwfns = 2;
354 if ((~p_iov->b_pre_fp_hsi &
355 ETH_HSI_VER_MINOR) &&
356 (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR))
358 "PF is using older fastpath HSI;"
359 " %02x.%02x is configured\n",
361 resp->pfdev_info.minor_fp_hsi);
364 ecore_vf_pf_req_end(p_hwfn, rc);
369 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn)
371 struct ecore_vf_iov *p_iov;
374 /* Set number of hwfns - might be overridden once leading hwfn learns
375 * actual configuration from PF.
377 if (IS_LEAD_HWFN(p_hwfn))
378 p_hwfn->p_dev->num_hwfns = 1;
380 /* Set the doorbell bar. Assumption: regview is set */
381 p_hwfn->doorbells = (u8 OSAL_IOMEM *)p_hwfn->regview +
382 PXP_VF_BAR0_START_DQ;
384 reg = PXP_VF_BAR0_ME_OPAQUE_ADDRESS;
385 p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn, reg);
387 reg = PXP_VF_BAR0_ME_CONCRETE_ADDRESS;
388 p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn, reg);
390 /* Allocate vf sriov info */
391 p_iov = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL, sizeof(*p_iov));
393 DP_NOTICE(p_hwfn, true,
394 "Failed to allocate `struct ecore_sriov'\n");
398 OSAL_MEMSET(p_iov, 0, sizeof(*p_iov));
400 /* Allocate vf2pf msg */
401 p_iov->vf2pf_request = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
406 if (!p_iov->vf2pf_request) {
407 DP_NOTICE(p_hwfn, true,
408 "Failed to allocate `vf2pf_request' DMA memory\n");
412 p_iov->pf2vf_reply = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
415 sizeof(union pfvf_tlvs));
416 if (!p_iov->pf2vf_reply) {
417 DP_NOTICE(p_hwfn, true,
418 "Failed to allocate `pf2vf_reply' DMA memory\n");
419 goto free_vf2pf_request;
422 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
423 "VF's Request mailbox [%p virt 0x%lx phys], "
424 "Response mailbox [%p virt 0x%lx phys]\n",
425 p_iov->vf2pf_request,
426 (unsigned long)p_iov->vf2pf_request_phys,
428 (unsigned long)p_iov->pf2vf_reply_phys);
430 /* Allocate Bulletin board */
431 p_iov->bulletin.size = sizeof(struct ecore_bulletin_content);
432 p_iov->bulletin.p_virt = OSAL_DMA_ALLOC_COHERENT(p_hwfn->p_dev,
437 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
438 "VF's bulletin Board [%p virt 0x%lx phys 0x%08x bytes]\n",
439 p_iov->bulletin.p_virt, (unsigned long)p_iov->bulletin.phys,
440 p_iov->bulletin.size);
442 OSAL_MUTEX_ALLOC(p_hwfn, &p_iov->mutex);
443 OSAL_MUTEX_INIT(&p_iov->mutex);
445 p_hwfn->vf_iov_info = p_iov;
447 p_hwfn->hw_info.personality = ECORE_PCI_ETH;
449 return ecore_vf_pf_acquire(p_hwfn);
452 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_iov->vf2pf_request,
453 p_iov->vf2pf_request_phys,
454 sizeof(union vfpf_tlvs));
456 OSAL_FREE(p_hwfn->p_dev, p_iov);
461 #define TSTORM_QZONE_START PXP_VF_BAR0_START_SDM_ZONE_A
462 #define MSTORM_QZONE_START(dev) (TSTORM_QZONE_START + \
463 (TSTORM_QZONE_SIZE * NUM_OF_L2_QUEUES(dev)))
465 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
470 dma_addr_t bd_chain_phys_addr,
471 dma_addr_t cqe_pbl_addr,
473 void OSAL_IOMEM **pp_prod)
475 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
476 struct pfvf_start_queue_resp_tlv *resp;
477 struct vfpf_start_rxq_tlv *req;
480 /* clear mailbox and prep first tlv */
481 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_RXQ, sizeof(*req));
483 req->rx_qid = rx_qid;
484 req->cqe_pbl_addr = cqe_pbl_addr;
485 req->cqe_pbl_size = cqe_pbl_size;
486 req->rxq_addr = bd_chain_phys_addr;
488 req->sb_index = sb_index;
489 req->bd_max_bytes = bd_max_bytes;
490 req->stat_id = -1; /* Keep initialized, for future compatibility */
492 /* If PF is legacy, we'll need to calculate producers ourselves
493 * as well as clean them.
495 if (pp_prod && p_iov->b_pre_fp_hsi) {
496 u8 hw_qid = p_iov->acquire_resp.resc.hw_qid[rx_qid];
497 u32 init_prod_val = 0;
499 *pp_prod = (u8 OSAL_IOMEM *)p_hwfn->regview +
500 MSTORM_QZONE_START(p_hwfn->p_dev) +
501 (hw_qid) * MSTORM_QZONE_SIZE;
503 /* Init the rcq, rx bd and rx sge (if valid) producers to 0 */
504 __internal_ram_wr(p_hwfn, *pp_prod, sizeof(u32),
505 (u32 *)(&init_prod_val));
508 /* add list termination tlv */
509 ecore_add_tlv(p_hwfn, &p_iov->offset,
510 CHANNEL_TLV_LIST_END,
511 sizeof(struct channel_list_end_tlv));
513 resp = &p_iov->pf2vf_reply->queue_start;
514 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
518 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
523 /* Learn the address of the producer from the response */
524 if (pp_prod && !p_iov->b_pre_fp_hsi) {
525 u32 init_prod_val = 0;
527 *pp_prod = (u8 OSAL_IOMEM *)p_hwfn->regview + resp->offset;
528 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
529 "Rxq[0x%02x]: producer at %p [offset 0x%08x]\n",
530 rx_qid, *pp_prod, resp->offset);
532 /* Init the rcq, rx bd and rx sge (if valid) producers to 0.
533 * It was actually the PF's responsibility, but since some
534 * old PFs might fail to do so, we do this as well.
536 OSAL_BUILD_BUG_ON(ETH_HSI_VER_MAJOR != 3);
537 __internal_ram_wr(p_hwfn, *pp_prod, sizeof(u32),
538 (u32 *)&init_prod_val);
542 ecore_vf_pf_req_end(p_hwfn, rc);
547 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
548 u16 rx_qid, bool cqe_completion)
550 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
551 struct vfpf_stop_rxqs_tlv *req;
552 struct pfvf_def_resp_tlv *resp;
555 /* clear mailbox and prep first tlv */
556 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_RXQS, sizeof(*req));
558 req->rx_qid = rx_qid;
560 req->cqe_completion = cqe_completion;
562 /* add list termination tlv */
563 ecore_add_tlv(p_hwfn, &p_iov->offset,
564 CHANNEL_TLV_LIST_END,
565 sizeof(struct channel_list_end_tlv));
567 resp = &p_iov->pf2vf_reply->default_resp;
568 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
572 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
578 ecore_vf_pf_req_end(p_hwfn, rc);
583 enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
589 void OSAL_IOMEM **pp_doorbell)
591 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
592 struct pfvf_start_queue_resp_tlv *resp;
593 struct vfpf_start_txq_tlv *req;
596 /* clear mailbox and prep first tlv */
597 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_TXQ, sizeof(*req));
599 req->tx_qid = tx_queue_id;
602 req->pbl_addr = pbl_addr;
603 req->pbl_size = pbl_size;
605 req->sb_index = sb_index;
607 /* add list termination tlv */
608 ecore_add_tlv(p_hwfn, &p_iov->offset,
609 CHANNEL_TLV_LIST_END,
610 sizeof(struct channel_list_end_tlv));
612 resp = &p_iov->pf2vf_reply->queue_start;
613 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
617 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
623 /* Modern PFs provide the actual offsets, while legacy
624 * provided only the queue id.
626 if (!p_iov->b_pre_fp_hsi) {
627 *pp_doorbell = (u8 OSAL_IOMEM *)p_hwfn->doorbells +
630 u8 cid = p_iov->acquire_resp.resc.cid[tx_queue_id];
632 *pp_doorbell = (u8 OSAL_IOMEM *)p_hwfn->doorbells +
633 DB_ADDR_VF(cid, DQ_DEMS_LEGACY);
636 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
637 "Txq[0x%02x]: doorbell at %p [offset 0x%08x]\n",
638 tx_queue_id, *pp_doorbell, resp->offset);
642 ecore_vf_pf_req_end(p_hwfn, rc);
647 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, u16 tx_qid)
649 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
650 struct vfpf_stop_txqs_tlv *req;
651 struct pfvf_def_resp_tlv *resp;
654 /* clear mailbox and prep first tlv */
655 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_TXQS, sizeof(*req));
657 req->tx_qid = tx_qid;
660 /* add list termination tlv */
661 ecore_add_tlv(p_hwfn, &p_iov->offset,
662 CHANNEL_TLV_LIST_END,
663 sizeof(struct channel_list_end_tlv));
665 resp = &p_iov->pf2vf_reply->default_resp;
666 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
670 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
676 ecore_vf_pf_req_end(p_hwfn, rc);
681 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
684 u8 comp_cqe_flg, u8 comp_event_flg)
686 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
687 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
688 struct vfpf_update_rxq_tlv *req;
691 /* clear mailbox and prep first tlv */
692 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UPDATE_RXQ, sizeof(*req));
694 req->rx_qid = rx_queue_id;
695 req->num_rxqs = num_rxqs;
698 req->flags |= VFPF_RXQ_UPD_COMPLETE_CQE_FLAG;
700 req->flags |= VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG;
702 /* add list termination tlv */
703 ecore_add_tlv(p_hwfn, &p_iov->offset,
704 CHANNEL_TLV_LIST_END,
705 sizeof(struct channel_list_end_tlv));
707 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
711 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
717 ecore_vf_pf_req_end(p_hwfn, rc);
723 ecore_vf_pf_vport_start(struct ecore_hwfn *p_hwfn, u8 vport_id,
724 u16 mtu, u8 inner_vlan_removal,
725 enum ecore_tpa_mode tpa_mode, u8 max_buffers_per_cqe,
728 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
729 struct vfpf_vport_start_tlv *req;
730 struct pfvf_def_resp_tlv *resp;
733 /* clear mailbox and prep first tlv */
734 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_START, sizeof(*req));
737 req->vport_id = vport_id;
738 req->inner_vlan_removal = inner_vlan_removal;
739 req->tpa_mode = tpa_mode;
740 req->max_buffers_per_cqe = max_buffers_per_cqe;
741 req->only_untagged = only_untagged;
744 for (i = 0; i < p_hwfn->vf_iov_info->acquire_resp.resc.num_sbs; i++)
745 if (p_hwfn->sbs_info[i])
746 req->sb_addr[i] = p_hwfn->sbs_info[i]->sb_phys;
748 /* add list termination tlv */
749 ecore_add_tlv(p_hwfn, &p_iov->offset,
750 CHANNEL_TLV_LIST_END,
751 sizeof(struct channel_list_end_tlv));
753 resp = &p_iov->pf2vf_reply->default_resp;
754 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
758 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
764 ecore_vf_pf_req_end(p_hwfn, rc);
769 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn)
771 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
772 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
775 /* clear mailbox and prep first tlv */
776 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_TEARDOWN,
777 sizeof(struct vfpf_first_tlv));
779 /* add list termination tlv */
780 ecore_add_tlv(p_hwfn, &p_iov->offset,
781 CHANNEL_TLV_LIST_END,
782 sizeof(struct channel_list_end_tlv));
784 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
788 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
794 ecore_vf_pf_req_end(p_hwfn, rc);
800 ecore_vf_handle_vp_update_is_needed(struct ecore_hwfn *p_hwfn,
801 struct ecore_sp_vport_update_params *p_data,
805 case CHANNEL_TLV_VPORT_UPDATE_ACTIVATE:
806 return !!(p_data->update_vport_active_rx_flg ||
807 p_data->update_vport_active_tx_flg);
808 case CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH:
810 /* FPGA doesn't have PVFC and so can't support tx-switching */
811 return !!(p_data->update_tx_switching_flg &&
812 !CHIP_REV_IS_FPGA(p_hwfn->p_dev));
814 return !!p_data->update_tx_switching_flg;
816 case CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP:
817 return !!p_data->update_inner_vlan_removal_flg;
818 case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN:
819 return !!p_data->update_accept_any_vlan_flg;
820 case CHANNEL_TLV_VPORT_UPDATE_MCAST:
821 return !!p_data->update_approx_mcast_flg;
822 case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM:
823 return !!(p_data->accept_flags.update_rx_mode_config ||
824 p_data->accept_flags.update_tx_mode_config);
825 case CHANNEL_TLV_VPORT_UPDATE_RSS:
826 return !!p_data->rss_params;
827 case CHANNEL_TLV_VPORT_UPDATE_SGE_TPA:
828 return !!p_data->sge_tpa_params;
830 DP_INFO(p_hwfn, "Unexpected vport-update TLV[%d] %s\n",
831 tlv, ecore_channel_tlvs_string[tlv]);
837 ecore_vf_handle_vp_update_tlvs_resp(struct ecore_hwfn *p_hwfn,
838 struct ecore_sp_vport_update_params *p_data)
840 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
841 struct pfvf_def_resp_tlv *p_resp;
844 for (tlv = CHANNEL_TLV_VPORT_UPDATE_ACTIVATE;
845 tlv < CHANNEL_TLV_VPORT_UPDATE_MAX;
847 if (!ecore_vf_handle_vp_update_is_needed(p_hwfn, p_data, tlv))
850 p_resp = (struct pfvf_def_resp_tlv *)
851 ecore_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply, tlv);
852 if (p_resp && p_resp->hdr.status)
853 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
854 "TLV[%d] type %s Configuration %s\n",
855 tlv, ecore_channel_tlvs_string[tlv],
856 (p_resp && p_resp->hdr.status) ? "succeeded"
862 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
863 struct ecore_sp_vport_update_params *p_params)
865 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
866 struct vfpf_vport_update_tlv *req;
867 struct pfvf_def_resp_tlv *resp;
868 u8 update_rx, update_tx;
873 resp = &p_iov->pf2vf_reply->default_resp;
874 resp_size = sizeof(*resp);
876 update_rx = p_params->update_vport_active_rx_flg;
877 update_tx = p_params->update_vport_active_tx_flg;
879 /* clear mailbox and prep header tlv */
880 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_UPDATE, sizeof(*req));
882 /* Prepare extended tlvs */
883 if (update_rx || update_tx) {
884 struct vfpf_vport_update_activate_tlv *p_act_tlv;
886 size = sizeof(struct vfpf_vport_update_activate_tlv);
887 p_act_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
888 CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
890 resp_size += sizeof(struct pfvf_def_resp_tlv);
893 p_act_tlv->update_rx = update_rx;
894 p_act_tlv->active_rx = p_params->vport_active_rx_flg;
898 p_act_tlv->update_tx = update_tx;
899 p_act_tlv->active_tx = p_params->vport_active_tx_flg;
903 if (p_params->update_inner_vlan_removal_flg) {
904 struct vfpf_vport_update_vlan_strip_tlv *p_vlan_tlv;
906 size = sizeof(struct vfpf_vport_update_vlan_strip_tlv);
907 p_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
908 CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
910 resp_size += sizeof(struct pfvf_def_resp_tlv);
912 p_vlan_tlv->remove_vlan = p_params->inner_vlan_removal_flg;
915 if (p_params->update_tx_switching_flg) {
916 struct vfpf_vport_update_tx_switch_tlv *p_tx_switch_tlv;
918 size = sizeof(struct vfpf_vport_update_tx_switch_tlv);
919 tlv = CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH;
920 p_tx_switch_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
922 resp_size += sizeof(struct pfvf_def_resp_tlv);
924 p_tx_switch_tlv->tx_switching = p_params->tx_switching_flg;
927 if (p_params->update_approx_mcast_flg) {
928 struct vfpf_vport_update_mcast_bin_tlv *p_mcast_tlv;
930 size = sizeof(struct vfpf_vport_update_mcast_bin_tlv);
931 p_mcast_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
932 CHANNEL_TLV_VPORT_UPDATE_MCAST,
934 resp_size += sizeof(struct pfvf_def_resp_tlv);
936 OSAL_MEMCPY(p_mcast_tlv->bins, p_params->bins,
937 sizeof(unsigned long) *
938 ETH_MULTICAST_MAC_BINS_IN_REGS);
941 update_rx = p_params->accept_flags.update_rx_mode_config;
942 update_tx = p_params->accept_flags.update_tx_mode_config;
944 if (update_rx || update_tx) {
945 struct vfpf_vport_update_accept_param_tlv *p_accept_tlv;
947 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM;
948 size = sizeof(struct vfpf_vport_update_accept_param_tlv);
949 p_accept_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset, tlv, size);
950 resp_size += sizeof(struct pfvf_def_resp_tlv);
953 p_accept_tlv->update_rx_mode = update_rx;
954 p_accept_tlv->rx_accept_filter =
955 p_params->accept_flags.rx_accept_filter;
959 p_accept_tlv->update_tx_mode = update_tx;
960 p_accept_tlv->tx_accept_filter =
961 p_params->accept_flags.tx_accept_filter;
965 if (p_params->rss_params) {
966 struct ecore_rss_params *rss_params = p_params->rss_params;
967 struct vfpf_vport_update_rss_tlv *p_rss_tlv;
969 size = sizeof(struct vfpf_vport_update_rss_tlv);
970 p_rss_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
971 CHANNEL_TLV_VPORT_UPDATE_RSS, size);
972 resp_size += sizeof(struct pfvf_def_resp_tlv);
974 if (rss_params->update_rss_config)
975 p_rss_tlv->update_rss_flags |=
976 VFPF_UPDATE_RSS_CONFIG_FLAG;
977 if (rss_params->update_rss_capabilities)
978 p_rss_tlv->update_rss_flags |=
979 VFPF_UPDATE_RSS_CAPS_FLAG;
980 if (rss_params->update_rss_ind_table)
981 p_rss_tlv->update_rss_flags |=
982 VFPF_UPDATE_RSS_IND_TABLE_FLAG;
983 if (rss_params->update_rss_key)
984 p_rss_tlv->update_rss_flags |= VFPF_UPDATE_RSS_KEY_FLAG;
986 p_rss_tlv->rss_enable = rss_params->rss_enable;
987 p_rss_tlv->rss_caps = rss_params->rss_caps;
988 p_rss_tlv->rss_table_size_log = rss_params->rss_table_size_log;
989 OSAL_MEMCPY(p_rss_tlv->rss_ind_table, rss_params->rss_ind_table,
990 sizeof(rss_params->rss_ind_table));
991 OSAL_MEMCPY(p_rss_tlv->rss_key, rss_params->rss_key,
992 sizeof(rss_params->rss_key));
995 if (p_params->update_accept_any_vlan_flg) {
996 struct vfpf_vport_update_accept_any_vlan_tlv *p_any_vlan_tlv;
998 size = sizeof(struct vfpf_vport_update_accept_any_vlan_tlv);
999 tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN;
1000 p_any_vlan_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
1003 resp_size += sizeof(struct pfvf_def_resp_tlv);
1004 p_any_vlan_tlv->accept_any_vlan = p_params->accept_any_vlan;
1005 p_any_vlan_tlv->update_accept_any_vlan_flg =
1006 p_params->update_accept_any_vlan_flg;
1009 if (p_params->sge_tpa_params) {
1010 struct ecore_sge_tpa_params *sge_tpa_params;
1011 struct vfpf_vport_update_sge_tpa_tlv *p_sge_tpa_tlv;
1013 sge_tpa_params = p_params->sge_tpa_params;
1014 size = sizeof(struct vfpf_vport_update_sge_tpa_tlv);
1015 p_sge_tpa_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
1016 CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
1018 resp_size += sizeof(struct pfvf_def_resp_tlv);
1020 if (sge_tpa_params->update_tpa_en_flg)
1021 p_sge_tpa_tlv->update_sge_tpa_flags |=
1022 VFPF_UPDATE_TPA_EN_FLAG;
1023 if (sge_tpa_params->update_tpa_param_flg)
1024 p_sge_tpa_tlv->update_sge_tpa_flags |=
1025 VFPF_UPDATE_TPA_PARAM_FLAG;
1027 if (sge_tpa_params->tpa_ipv4_en_flg)
1028 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV4_EN_FLAG;
1029 if (sge_tpa_params->tpa_ipv6_en_flg)
1030 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_IPV6_EN_FLAG;
1031 if (sge_tpa_params->tpa_pkt_split_flg)
1032 p_sge_tpa_tlv->sge_tpa_flags |= VFPF_TPA_PKT_SPLIT_FLAG;
1033 if (sge_tpa_params->tpa_hdr_data_split_flg)
1034 p_sge_tpa_tlv->sge_tpa_flags |=
1035 VFPF_TPA_HDR_DATA_SPLIT_FLAG;
1036 if (sge_tpa_params->tpa_gro_consistent_flg)
1037 p_sge_tpa_tlv->sge_tpa_flags |=
1038 VFPF_TPA_GRO_CONSIST_FLAG;
1040 p_sge_tpa_tlv->tpa_max_aggs_num =
1041 sge_tpa_params->tpa_max_aggs_num;
1042 p_sge_tpa_tlv->tpa_max_size = sge_tpa_params->tpa_max_size;
1043 p_sge_tpa_tlv->tpa_min_size_to_start =
1044 sge_tpa_params->tpa_min_size_to_start;
1045 p_sge_tpa_tlv->tpa_min_size_to_cont =
1046 sge_tpa_params->tpa_min_size_to_cont;
1048 p_sge_tpa_tlv->max_buffers_per_cqe =
1049 sge_tpa_params->max_buffers_per_cqe;
1052 /* add list termination tlv */
1053 ecore_add_tlv(p_hwfn, &p_iov->offset,
1054 CHANNEL_TLV_LIST_END,
1055 sizeof(struct channel_list_end_tlv));
1057 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, resp_size);
1061 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1066 ecore_vf_handle_vp_update_tlvs_resp(p_hwfn, p_params);
1069 ecore_vf_pf_req_end(p_hwfn, rc);
1074 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn)
1076 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1077 struct pfvf_def_resp_tlv *resp;
1078 struct vfpf_first_tlv *req;
1081 /* clear mailbox and prep first tlv */
1082 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_CLOSE, sizeof(*req));
1084 /* add list termination tlv */
1085 ecore_add_tlv(p_hwfn, &p_iov->offset,
1086 CHANNEL_TLV_LIST_END,
1087 sizeof(struct channel_list_end_tlv));
1089 resp = &p_iov->pf2vf_reply->default_resp;
1090 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1094 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1099 p_hwfn->b_int_enabled = 0;
1102 ecore_vf_pf_req_end(p_hwfn, rc);
1107 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn)
1109 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1110 struct pfvf_def_resp_tlv *resp;
1111 struct vfpf_first_tlv *req;
1115 /* clear mailbox and prep first tlv */
1116 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_RELEASE, sizeof(*req));
1118 /* add list termination tlv */
1119 ecore_add_tlv(p_hwfn, &p_iov->offset,
1120 CHANNEL_TLV_LIST_END,
1121 sizeof(struct channel_list_end_tlv));
1123 resp = &p_iov->pf2vf_reply->default_resp;
1124 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1126 if (rc == ECORE_SUCCESS && resp->hdr.status != PFVF_STATUS_SUCCESS)
1129 ecore_vf_pf_req_end(p_hwfn, rc);
1131 p_hwfn->b_int_enabled = 0;
1133 if (p_iov->vf2pf_request)
1134 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1135 p_iov->vf2pf_request,
1136 p_iov->vf2pf_request_phys,
1137 sizeof(union vfpf_tlvs));
1138 if (p_iov->pf2vf_reply)
1139 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1141 p_iov->pf2vf_reply_phys,
1142 sizeof(union pfvf_tlvs));
1144 if (p_iov->bulletin.p_virt) {
1145 size = sizeof(struct ecore_bulletin_content);
1146 OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev,
1147 p_iov->bulletin.p_virt,
1148 p_iov->bulletin.phys, size);
1151 OSAL_FREE(p_hwfn->p_dev, p_hwfn->vf_iov_info);
1152 p_hwfn->vf_iov_info = OSAL_NULL;
1157 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
1158 struct ecore_filter_mcast *p_filter_cmd)
1160 struct ecore_sp_vport_update_params sp_params;
1163 OSAL_MEMSET(&sp_params, 0, sizeof(sp_params));
1164 sp_params.update_approx_mcast_flg = 1;
1166 if (p_filter_cmd->opcode == ECORE_FILTER_ADD) {
1167 for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) {
1170 bit = ecore_mcast_bin_from_mac(p_filter_cmd->mac[i]);
1171 OSAL_SET_BIT(bit, sp_params.bins);
1175 ecore_vf_pf_vport_update(p_hwfn, &sp_params);
1178 enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn *p_hwfn,
1179 struct ecore_filter_ucast
1182 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1183 struct vfpf_ucast_filter_tlv *req;
1184 struct pfvf_def_resp_tlv *resp;
1188 if (p_ucast->opcode == ECORE_FILTER_MOVE) {
1189 DP_NOTICE(p_hwfn, true,
1190 "VFs don't support Moving of filters\n");
1194 /* clear mailbox and prep first tlv */
1195 req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_UCAST_FILTER, sizeof(*req));
1196 req->opcode = (u8)p_ucast->opcode;
1197 req->type = (u8)p_ucast->type;
1198 OSAL_MEMCPY(req->mac, p_ucast->mac, ETH_ALEN);
1199 req->vlan = p_ucast->vlan;
1201 /* add list termination tlv */
1202 ecore_add_tlv(p_hwfn, &p_iov->offset,
1203 CHANNEL_TLV_LIST_END,
1204 sizeof(struct channel_list_end_tlv));
1206 resp = &p_iov->pf2vf_reply->default_resp;
1207 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1211 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1217 ecore_vf_pf_req_end(p_hwfn, rc);
1222 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn)
1224 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1225 struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
1228 /* clear mailbox and prep first tlv */
1229 ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_INT_CLEANUP,
1230 sizeof(struct vfpf_first_tlv));
1232 /* add list termination tlv */
1233 ecore_add_tlv(p_hwfn, &p_iov->offset,
1234 CHANNEL_TLV_LIST_END,
1235 sizeof(struct channel_list_end_tlv));
1237 rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
1241 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
1247 ecore_vf_pf_req_end(p_hwfn, rc);
1252 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
1255 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1258 DP_NOTICE(p_hwfn, true, "vf_sriov_info isn't initialized\n");
1262 return p_iov->acquire_resp.resc.hw_sbs[sb_id].hw_sb_id;
1265 enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn,
1268 struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
1269 struct ecore_bulletin_content shadow;
1272 crc_size = sizeof(p_iov->bulletin.p_virt->crc);
1275 /* Need to guarantee PF is not in the middle of writing it */
1276 OSAL_MEMCPY(&shadow, p_iov->bulletin.p_virt, p_iov->bulletin.size);
1278 /* If version did not update, no need to do anything */
1279 if (shadow.version == p_iov->bulletin_shadow.version)
1280 return ECORE_SUCCESS;
1282 /* Verify the bulletin we see is valid */
1283 crc = ecore_crc32(0, (u8 *)&shadow + crc_size,
1284 p_iov->bulletin.size - crc_size);
1285 if (crc != shadow.crc)
1288 /* Set the shadow bulletin and process it */
1289 OSAL_MEMCPY(&p_iov->bulletin_shadow, &shadow, p_iov->bulletin.size);
1291 DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
1292 "Read a bulletin update %08x\n", shadow.version);
1296 return ECORE_SUCCESS;
1299 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1300 struct ecore_mcp_link_params *p_params,
1301 struct ecore_bulletin_content *p_bulletin)
1303 OSAL_MEMSET(p_params, 0, sizeof(*p_params));
1305 p_params->speed.autoneg = p_bulletin->req_autoneg;
1306 p_params->speed.advertised_speeds = p_bulletin->req_adv_speed;
1307 p_params->speed.forced_speed = p_bulletin->req_forced_speed;
1308 p_params->pause.autoneg = p_bulletin->req_autoneg_pause;
1309 p_params->pause.forced_rx = p_bulletin->req_forced_rx;
1310 p_params->pause.forced_tx = p_bulletin->req_forced_tx;
1311 p_params->loopback_mode = p_bulletin->req_loopback;
1314 void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
1315 struct ecore_mcp_link_params *params)
1317 __ecore_vf_get_link_params(p_hwfn, params,
1318 &p_hwfn->vf_iov_info->bulletin_shadow);
1321 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1322 struct ecore_mcp_link_state *p_link,
1323 struct ecore_bulletin_content *p_bulletin)
1325 OSAL_MEMSET(p_link, 0, sizeof(*p_link));
1327 p_link->link_up = p_bulletin->link_up;
1328 p_link->speed = p_bulletin->speed;
1329 p_link->full_duplex = p_bulletin->full_duplex;
1330 p_link->an = p_bulletin->autoneg;
1331 p_link->an_complete = p_bulletin->autoneg_complete;
1332 p_link->parallel_detection = p_bulletin->parallel_detection;
1333 p_link->pfc_enabled = p_bulletin->pfc_enabled;
1334 p_link->partner_adv_speed = p_bulletin->partner_adv_speed;
1335 p_link->partner_tx_flow_ctrl_en = p_bulletin->partner_tx_flow_ctrl_en;
1336 p_link->partner_rx_flow_ctrl_en = p_bulletin->partner_rx_flow_ctrl_en;
1337 p_link->partner_adv_pause = p_bulletin->partner_adv_pause;
1338 p_link->sfp_tx_fault = p_bulletin->sfp_tx_fault;
1341 void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
1342 struct ecore_mcp_link_state *link)
1344 __ecore_vf_get_link_state(p_hwfn, link,
1345 &p_hwfn->vf_iov_info->bulletin_shadow);
1348 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1349 struct ecore_mcp_link_capabilities *p_link_caps,
1350 struct ecore_bulletin_content *p_bulletin)
1352 OSAL_MEMSET(p_link_caps, 0, sizeof(*p_link_caps));
1353 p_link_caps->speed_capabilities = p_bulletin->capability_speed;
1356 void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
1357 struct ecore_mcp_link_capabilities *p_link_caps)
1359 __ecore_vf_get_link_caps(p_hwfn, p_link_caps,
1360 &p_hwfn->vf_iov_info->bulletin_shadow);
1363 void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, u8 *num_rxqs)
1365 *num_rxqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_rxqs;
1368 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, u8 *port_mac)
1370 OSAL_MEMCPY(port_mac,
1371 p_hwfn->vf_iov_info->acquire_resp.pfdev_info.port_mac,
1375 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn,
1376 u8 *num_vlan_filters)
1378 struct ecore_vf_iov *p_vf;
1380 p_vf = p_hwfn->vf_iov_info;
1381 *num_vlan_filters = p_vf->acquire_resp.resc.num_vlan_filters;
1385 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn,
1388 struct ecore_vf_iov *p_vf;
1390 p_vf = p_hwfn->vf_iov_info;
1391 *num_mac = p_vf->acquire_resp.resc.num_mac_filters;
1394 void ecore_vf_get_num_sbs(struct ecore_hwfn *p_hwfn,
1397 struct ecore_vf_iov *p_vf;
1399 p_vf = p_hwfn->vf_iov_info;
1400 *num_sbs = (u32)p_vf->acquire_resp.resc.num_sbs;
1403 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac)
1405 struct ecore_bulletin_content *bulletin;
1407 bulletin = &p_hwfn->vf_iov_info->bulletin_shadow;
1408 if (!(bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)))
1411 /* Forbid VF from changing a MAC enforced by PF */
1412 if (OSAL_MEMCMP(bulletin->mac, mac, ETH_ALEN))
1418 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
1421 struct ecore_bulletin_content *bulletin;
1423 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1425 if (bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)) {
1428 } else if (bulletin->valid_bitmap & (1 << VFPF_BULLETIN_MAC_ADDR)) {
1435 OSAL_MEMCPY(dst_mac, bulletin->mac, ETH_ALEN);
1440 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid)
1442 struct ecore_bulletin_content *bulletin;
1444 bulletin = &hwfn->vf_iov_info->bulletin_shadow;
1446 if (!(bulletin->valid_bitmap & (1 << VLAN_ADDR_FORCED)))
1450 *dst_pvid = bulletin->pvid;
1455 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn)
1457 return p_hwfn->vf_iov_info->b_pre_fp_hsi;
1460 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn,
1461 u16 *fw_major, u16 *fw_minor, u16 *fw_rev,
1464 struct pf_vf_pfdev_info *info;
1466 info = &p_hwfn->vf_iov_info->acquire_resp.pfdev_info;
1468 *fw_major = info->fw_major;
1469 *fw_minor = info->fw_minor;
1470 *fw_rev = info->fw_rev;
1471 *fw_eng = info->fw_eng;