2 * Copyright (C) 2013 Emulex
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Emulex Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
31 * Contact Information:
32 * freebsd-drivers@emulex.com
36 * Costa Mesa, CA 92626
42 extern uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE];
45 * @brief Reset (firmware) common function
46 * @param sc software handle to the device
47 * @returns 0 on success, ETIMEDOUT on failure
50 oce_reset_fun(POCE_SOFTC sc)
54 struct ioctl_common_function_reset *fwcmd;
57 if (sc->flags & OCE_FLAGS_FUNCRESET_RQD) {
58 mb = OCE_DMAPTR(&sc->bsmbx, struct oce_bmbx);
60 bzero(mbx, sizeof(struct oce_mbx));
62 fwcmd = (struct ioctl_common_function_reset *)&mbx->payload;
63 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
65 OPCODE_COMMON_FUNCTION_RESET,
66 10, /* MBX_TIMEOUT_SEC */
68 ioctl_common_function_reset),
71 mbx->u0.s.embedded = 1;
73 sizeof(struct ioctl_common_function_reset);
75 rc = oce_mbox_dispatch(sc, 2);
83 * @brief This funtions tells firmware we are
85 * @param sc software handle to the device
86 * @returns 0 on success, ETIMEDOUT on failure
89 oce_fw_clean(POCE_SOFTC sc)
95 mbx = OCE_DMAPTR(&sc->bsmbx, struct oce_bmbx);
96 ptr = (uint8_t *) &mbx->mbx;
98 /* Endian Signature */
108 ret = oce_mbox_dispatch(sc, 2);
115 * @brief Mailbox wait
116 * @param sc software handle to the device
117 * @param tmo_sec timeout in seconds
120 oce_mbox_wait(POCE_SOFTC sc, uint32_t tmo_sec)
123 pd_mpu_mbox_db_t mbox_db;
131 mbox_db.dw0 = OCE_READ_REG32(sc, db, PD_MPU_MBOX_DB);
133 if (mbox_db.bits.ready)
139 device_printf(sc->dev, "Mailbox timed out\n");
146 * @brief Mailbox dispatch
147 * @param sc software handle to the device
148 * @param tmo_sec timeout in seconds
151 oce_mbox_dispatch(POCE_SOFTC sc, uint32_t tmo_sec)
153 pd_mpu_mbox_db_t mbox_db;
157 oce_dma_sync(&sc->bsmbx, BUS_DMASYNC_PREWRITE);
158 pa = (uint32_t) ((uint64_t) sc->bsmbx.paddr >> 34);
159 bzero(&mbox_db, sizeof(pd_mpu_mbox_db_t));
160 mbox_db.bits.ready = 0;
162 mbox_db.bits.address = pa;
164 rc = oce_mbox_wait(sc, tmo_sec);
166 OCE_WRITE_REG32(sc, db, PD_MPU_MBOX_DB, mbox_db.dw0);
168 pa = (uint32_t) ((uint64_t) sc->bsmbx.paddr >> 4) & 0x3fffffff;
169 mbox_db.bits.ready = 0;
171 mbox_db.bits.address = pa;
173 rc = oce_mbox_wait(sc, tmo_sec);
176 OCE_WRITE_REG32(sc, db, PD_MPU_MBOX_DB, mbox_db.dw0);
178 rc = oce_mbox_wait(sc, tmo_sec);
180 oce_dma_sync(&sc->bsmbx, BUS_DMASYNC_POSTWRITE);
190 * @brief Mailbox common request header initialization
191 * @param hdr mailbox header
194 * @param subsys subsystem
195 * @param opcode opcode
196 * @param timeout timeout
197 * @param pyld_len payload length
200 mbx_common_req_hdr_init(struct mbx_hdr *hdr,
201 uint8_t dom, uint8_t port,
202 uint8_t subsys, uint8_t opcode,
203 uint32_t timeout, uint32_t pyld_len,
206 hdr->u0.req.opcode = opcode;
207 hdr->u0.req.subsystem = subsys;
208 hdr->u0.req.port_number = port;
209 hdr->u0.req.domain = dom;
211 hdr->u0.req.timeout = timeout;
212 hdr->u0.req.request_length = pyld_len - sizeof(struct mbx_hdr);
213 hdr->u0.req.version = version;
219 * @brief Function to initialize the hw with host endian information
220 * @param sc software handle to the device
221 * @returns 0 on success, ETIMEDOUT on failure
224 oce_mbox_init(POCE_SOFTC sc)
226 struct oce_bmbx *mbx;
230 if (sc->flags & OCE_FLAGS_MBOX_ENDIAN_RQD) {
231 mbx = OCE_DMAPTR(&sc->bsmbx, struct oce_bmbx);
232 ptr = (uint8_t *) &mbx->mbx;
234 /* Endian Signature */
244 ret = oce_mbox_dispatch(sc, 0);
252 * @brief Function to get the firmware version
253 * @param sc software handle to the device
254 * @returns 0 on success, EIO on failure
257 oce_get_fw_version(POCE_SOFTC sc)
260 struct mbx_get_common_fw_version *fwcmd;
263 bzero(&mbx, sizeof(struct oce_mbx));
265 fwcmd = (struct mbx_get_common_fw_version *)&mbx.payload;
266 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
267 MBX_SUBSYSTEM_COMMON,
268 OPCODE_COMMON_GET_FW_VERSION,
270 sizeof(struct mbx_get_common_fw_version),
273 mbx.u0.s.embedded = 1;
274 mbx.payload_length = sizeof(struct mbx_get_common_fw_version);
275 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
277 ret = oce_mbox_post(sc, &mbx, NULL);
279 ret = fwcmd->hdr.u0.rsp.status;
281 device_printf(sc->dev,
282 "%s failed - cmd status: %d addi status: %d\n",
284 fwcmd->hdr.u0.rsp.additional_status);
288 bcopy(fwcmd->params.rsp.fw_ver_str, sc->fw_version, 32);
295 * @brief Firmware will send gracious notifications during
296 * attach only after sending first mcc commnad. We
297 * use MCC queue only for getting async and mailbox
298 * for sending cmds. So to get gracious notifications
299 * atleast send one dummy command on mcc.
302 oce_first_mcc_cmd(POCE_SOFTC sc)
305 struct oce_mq *mq = sc->mq;
306 struct mbx_get_common_fw_version *fwcmd;
309 mbx = RING_GET_PRODUCER_ITEM_VA(mq->ring, struct oce_mbx);
310 bzero(mbx, sizeof(struct oce_mbx));
312 fwcmd = (struct mbx_get_common_fw_version *)&mbx->payload;
313 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
314 MBX_SUBSYSTEM_COMMON,
315 OPCODE_COMMON_GET_FW_VERSION,
317 sizeof(struct mbx_get_common_fw_version),
319 mbx->u0.s.embedded = 1;
320 mbx->payload_length = sizeof(struct mbx_get_common_fw_version);
321 bus_dmamap_sync(mq->ring->dma.tag, mq->ring->dma.map,
322 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
323 RING_PUT(mq->ring, 1);
324 reg_value = (1 << 16) | mq->mq_id;
325 OCE_WRITE_REG32(sc, db, PD_MQ_DB, reg_value);
331 * @brief Function to post a MBX to the mbox
332 * @param sc software handle to the device
333 * @param mbx pointer to the MBX to send
334 * @param mbxctx pointer to the mbx context structure
335 * @returns 0 on success, error on failure
338 oce_mbox_post(POCE_SOFTC sc, struct oce_mbx *mbx, struct oce_mbx_ctx *mbxctx)
340 struct oce_mbx *mb_mbx = NULL;
341 struct oce_mq_cqe *mb_cqe = NULL;
342 struct oce_bmbx *mb = NULL;
345 uint32_t cstatus = 0;
346 uint32_t xstatus = 0;
348 LOCK(&sc->bmbx_lock);
350 mb = OCE_DMAPTR(&sc->bsmbx, struct oce_bmbx);
357 /* copy mbx into mbox */
358 bcopy(mbx, mb_mbx, sizeof(struct oce_mbx));
361 rc = oce_mbox_dispatch(sc, tmo);
364 * the command completed successfully. Now get the
365 * completion queue entry
368 DW_SWAP(u32ptr(&mb_cqe->u0.dw[0]), sizeof(struct oce_mq_cqe));
370 /* copy mbox mbx back */
371 bcopy(mb_mbx, mbx, sizeof(struct oce_mbx));
373 /* pick up the mailbox status */
374 cstatus = mb_cqe->u0.s.completion_status;
375 xstatus = mb_cqe->u0.s.extended_status;
378 * store the mbx context in the cqe tag section so that
379 * the upper layer handling the cqe can associate the mbx
382 if (cstatus == 0 && mbxctx) {
384 mbxctx->mbx = mb_mbx;
385 bcopy(&mbxctx, mb_cqe->u0.s.mq_tag,
386 sizeof(struct oce_mbx_ctx *));
390 UNLOCK(&sc->bmbx_lock);
396 * @brief Function to read the mac address associated with an interface
397 * @param sc software handle to the device
398 * @param if_id interface id to read the address from
399 * @param perm set to 1 if reading the factory mac address.
400 * In this case if_id is ignored
401 * @param type type of the mac address, whether network or storage
402 * @param[out] mac [OUTPUT] pointer to a buffer containing the
403 * mac address when the command succeeds.
404 * @returns 0 on success, EIO on failure
407 oce_read_mac_addr(POCE_SOFTC sc, uint32_t if_id,
408 uint8_t perm, uint8_t type, struct mac_address_format *mac)
411 struct mbx_query_common_iface_mac *fwcmd;
414 bzero(&mbx, sizeof(struct oce_mbx));
416 fwcmd = (struct mbx_query_common_iface_mac *)&mbx.payload;
417 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
418 MBX_SUBSYSTEM_COMMON,
419 OPCODE_COMMON_QUERY_IFACE_MAC,
421 sizeof(struct mbx_query_common_iface_mac),
424 fwcmd->params.req.permanent = perm;
426 fwcmd->params.req.if_id = (uint16_t) if_id;
428 fwcmd->params.req.if_id = 0;
430 fwcmd->params.req.type = type;
432 mbx.u0.s.embedded = 1;
433 mbx.payload_length = sizeof(struct mbx_query_common_iface_mac);
434 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
436 ret = oce_mbox_post(sc, &mbx, NULL);
438 ret = fwcmd->hdr.u0.rsp.status;
440 device_printf(sc->dev,
441 "%s failed - cmd status: %d addi status: %d\n",
443 fwcmd->hdr.u0.rsp.additional_status);
447 /* copy the mac addres in the output parameter */
448 mac->size_of_struct = fwcmd->params.rsp.mac.size_of_struct;
449 bcopy(&fwcmd->params.rsp.mac.mac_addr[0], &mac->mac_addr[0],
450 mac->size_of_struct);
456 * @brief Function to query the fw attributes from the hw
457 * @param sc software handle to the device
458 * @returns 0 on success, EIO on failure
461 oce_get_fw_config(POCE_SOFTC sc)
464 struct mbx_common_query_fw_config *fwcmd;
467 bzero(&mbx, sizeof(struct oce_mbx));
469 fwcmd = (struct mbx_common_query_fw_config *)&mbx.payload;
470 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
471 MBX_SUBSYSTEM_COMMON,
472 OPCODE_COMMON_QUERY_FIRMWARE_CONFIG,
474 sizeof(struct mbx_common_query_fw_config),
477 mbx.u0.s.embedded = 1;
478 mbx.payload_length = sizeof(struct mbx_common_query_fw_config);
479 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
481 ret = oce_mbox_post(sc, &mbx, NULL);
483 ret = fwcmd->hdr.u0.rsp.status;
485 device_printf(sc->dev,
486 "%s failed - cmd status: %d addi status: %d\n",
488 fwcmd->hdr.u0.rsp.additional_status);
492 DW_SWAP(u32ptr(fwcmd), sizeof(struct mbx_common_query_fw_config));
494 sc->config_number = HOST_32(fwcmd->params.rsp.config_number);
495 sc->asic_revision = HOST_32(fwcmd->params.rsp.asic_revision);
496 sc->port_id = HOST_32(fwcmd->params.rsp.port_id);
497 sc->function_mode = HOST_32(fwcmd->params.rsp.function_mode);
498 sc->function_caps = HOST_32(fwcmd->params.rsp.function_caps);
500 if (fwcmd->params.rsp.ulp[0].ulp_mode & ULP_NIC_MODE) {
501 sc->max_tx_rings = HOST_32(fwcmd->params.rsp.ulp[0].nic_wq_tot);
502 sc->max_rx_rings = HOST_32(fwcmd->params.rsp.ulp[0].lro_rqid_tot);
504 sc->max_tx_rings = HOST_32(fwcmd->params.rsp.ulp[1].nic_wq_tot);
505 sc->max_rx_rings = HOST_32(fwcmd->params.rsp.ulp[1].lro_rqid_tot);
515 * @brief function to create a device interface
516 * @param sc software handle to the device
517 * @param cap_flags capability flags
518 * @param en_flags enable capability flags
519 * @param vlan_tag optional vlan tag to associate with the if
520 * @param mac_addr pointer to a buffer containing the mac address
521 * @param[out] if_id [OUTPUT] pointer to an integer to hold the ID of the
523 * @returns 0 on success, EIO on failure
526 oce_if_create(POCE_SOFTC sc,
534 struct mbx_create_common_iface *fwcmd;
537 bzero(&mbx, sizeof(struct oce_mbx));
539 fwcmd = (struct mbx_create_common_iface *)&mbx.payload;
540 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
541 MBX_SUBSYSTEM_COMMON,
542 OPCODE_COMMON_CREATE_IFACE,
544 sizeof(struct mbx_create_common_iface),
546 DW_SWAP(u32ptr(&fwcmd->hdr), sizeof(struct mbx_hdr));
548 fwcmd->params.req.version = 0;
549 fwcmd->params.req.cap_flags = LE_32(cap_flags);
550 fwcmd->params.req.enable_flags = LE_32(en_flags);
551 if (mac_addr != NULL) {
552 bcopy(mac_addr, &fwcmd->params.req.mac_addr[0], 6);
553 fwcmd->params.req.vlan_tag.u0.normal.vtag = LE_16(vlan_tag);
554 fwcmd->params.req.mac_invalid = 0;
556 fwcmd->params.req.mac_invalid = 1;
559 mbx.u0.s.embedded = 1;
560 mbx.payload_length = sizeof(struct mbx_create_common_iface);
561 DW_SWAP(u32ptr(&mbx), OCE_BMBX_RHDR_SZ);
563 rc = oce_mbox_post(sc, &mbx, NULL);
565 rc = fwcmd->hdr.u0.rsp.status;
567 device_printf(sc->dev,
568 "%s failed - cmd status: %d addi status: %d\n",
570 fwcmd->hdr.u0.rsp.additional_status);
574 *if_id = HOST_32(fwcmd->params.rsp.if_id);
576 if (mac_addr != NULL)
577 sc->pmac_id = HOST_32(fwcmd->params.rsp.pmac_id);
583 * @brief Function to delete an interface
584 * @param sc software handle to the device
585 * @param if_id ID of the interface to delete
586 * @returns 0 on success, EIO on failure
589 oce_if_del(POCE_SOFTC sc, uint32_t if_id)
592 struct mbx_destroy_common_iface *fwcmd;
595 bzero(&mbx, sizeof(struct oce_mbx));
597 fwcmd = (struct mbx_destroy_common_iface *)&mbx.payload;
598 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
599 MBX_SUBSYSTEM_COMMON,
600 OPCODE_COMMON_DESTROY_IFACE,
602 sizeof(struct mbx_destroy_common_iface),
605 fwcmd->params.req.if_id = if_id;
607 mbx.u0.s.embedded = 1;
608 mbx.payload_length = sizeof(struct mbx_destroy_common_iface);
609 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
611 rc = oce_mbox_post(sc, &mbx, NULL);
613 rc = fwcmd->hdr.u0.rsp.status;
615 device_printf(sc->dev,
616 "%s failed - cmd status: %d addi status: %d\n",
618 fwcmd->hdr.u0.rsp.additional_status);
623 * @brief Function to send the mbx command to configure vlan
624 * @param sc software handle to the device
625 * @param if_id interface identifier index
626 * @param vtag_arr array of vlan tags
627 * @param vtag_cnt number of elements in array
628 * @param untagged boolean TRUE/FLASE
629 * @param enable_promisc flag to enable/disable VLAN promiscuous mode
630 * @returns 0 on success, EIO on failure
633 oce_config_vlan(POCE_SOFTC sc,
635 struct normal_vlan *vtag_arr,
636 uint8_t vtag_cnt, uint32_t untagged, uint32_t enable_promisc)
639 struct mbx_common_config_vlan *fwcmd;
642 if (sc->vlans_added > sc->max_vlans)
645 bzero(&mbx, sizeof(struct oce_mbx));
646 fwcmd = (struct mbx_common_config_vlan *)&mbx.payload;
648 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
649 MBX_SUBSYSTEM_COMMON,
650 OPCODE_COMMON_CONFIG_IFACE_VLAN,
652 sizeof(struct mbx_common_config_vlan),
655 fwcmd->params.req.if_id = (uint8_t) if_id;
656 fwcmd->params.req.promisc = (uint8_t) enable_promisc;
657 fwcmd->params.req.untagged = (uint8_t) untagged;
658 fwcmd->params.req.num_vlans = vtag_cnt;
660 if (!enable_promisc) {
661 bcopy(vtag_arr, fwcmd->params.req.tags.normal_vlans,
662 vtag_cnt * sizeof(struct normal_vlan));
664 mbx.u0.s.embedded = 1;
665 mbx.payload_length = sizeof(struct mbx_common_config_vlan);
666 DW_SWAP(u32ptr(&mbx), (OCE_BMBX_RHDR_SZ + mbx.payload_length));
668 rc = oce_mbox_post(sc, &mbx, NULL);
670 rc = fwcmd->hdr.u0.rsp.status;
672 device_printf(sc->dev,
673 "%s failed - cmd status: %d addi status: %d\n",
675 fwcmd->hdr.u0.rsp.additional_status);
680 /* Enable Vlan Promis */
681 oce_rxf_set_promiscuous(sc, (1 << 1));
682 device_printf(sc->dev,"Enabling Vlan Promisc Mode\n");
689 * @brief Function to set flow control capability in the hardware
690 * @param sc software handle to the device
691 * @param flow_control flow control flags to set
692 * @returns 0 on success, EIO on failure
695 oce_set_flow_control(POCE_SOFTC sc, uint32_t flow_control)
698 struct mbx_common_get_set_flow_control *fwcmd =
699 (struct mbx_common_get_set_flow_control *)&mbx.payload;
702 bzero(&mbx, sizeof(struct oce_mbx));
704 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
705 MBX_SUBSYSTEM_COMMON,
706 OPCODE_COMMON_SET_FLOW_CONTROL,
708 sizeof(struct mbx_common_get_set_flow_control),
711 if (flow_control & OCE_FC_TX)
712 fwcmd->tx_flow_control = 1;
714 if (flow_control & OCE_FC_RX)
715 fwcmd->rx_flow_control = 1;
717 mbx.u0.s.embedded = 1;
718 mbx.payload_length = sizeof(struct mbx_common_get_set_flow_control);
719 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
721 rc = oce_mbox_post(sc, &mbx, NULL);
723 rc = fwcmd->hdr.u0.rsp.status;
725 device_printf(sc->dev,
726 "%s failed - cmd status: %d addi status: %d\n",
728 fwcmd->hdr.u0.rsp.additional_status);
733 * @brief Initialize the RSS CPU indirection table
735 * The table is used to choose the queue to place the incomming packets.
736 * Incomming packets are hashed. The lowest bits in the hash result
737 * are used as the index into the CPU indirection table.
738 * Each entry in the table contains the RSS CPU-ID returned by the NIC
739 * create. Based on the CPU ID, the receive completion is routed to
740 * the corresponding RSS CQs. (Non-RSS packets are always completed
741 * on the default (0) CQ).
743 * @param sc software handle to the device
744 * @param *fwcmd pointer to the rss mbox command
748 oce_rss_itbl_init(POCE_SOFTC sc, struct mbx_config_nic_rss *fwcmd)
750 int i = 0, j = 0, rc = 0;
751 uint8_t *tbl = fwcmd->params.req.cputable;
752 struct oce_rq *rq = NULL;
755 for (j = 0; j < INDIRECTION_TABLE_ENTRIES ; j += (sc->nrqs - 1)) {
756 for_all_rss_queues(sc, rq, i) {
757 if ((j + i) >= INDIRECTION_TABLE_ENTRIES)
759 tbl[j + i] = rq->rss_cpuid;
763 device_printf(sc->dev, "error: Invalid number of RSS RQ's\n");
768 /* fill log2 value indicating the size of the CPU table */
770 fwcmd->params.req.cpu_tbl_sz_log2 = LE_16(OCE_LOG2(i));
776 * @brief Function to set flow control capability in the hardware
777 * @param sc software handle to the device
778 * @param if_id interface id to read the address from
779 * @param enable_rss 0=disable, RSS_ENABLE_xxx flags otherwise
780 * @returns 0 on success, EIO on failure
783 oce_config_nic_rss(POCE_SOFTC sc, uint32_t if_id, uint16_t enable_rss)
787 struct mbx_config_nic_rss *fwcmd =
788 (struct mbx_config_nic_rss *)&mbx.payload;
791 bzero(&mbx, sizeof(struct oce_mbx));
793 if (IS_XE201(sc) || IS_SH(sc)) {
794 version = OCE_MBX_VER_V1;
795 fwcmd->params.req.enable_rss = RSS_ENABLE_UDP_IPV4 |
798 version = OCE_MBX_VER_V0;
800 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
804 sizeof(struct mbx_config_nic_rss),
807 fwcmd->params.req.enable_rss |= (RSS_ENABLE_IPV4 |
808 RSS_ENABLE_TCP_IPV4 |
810 RSS_ENABLE_TCP_IPV6);
811 fwcmd->params.req.flush = OCE_FLUSH;
812 fwcmd->params.req.if_id = LE_32(if_id);
814 read_random(fwcmd->params.req.hash, sizeof(fwcmd->params.req.hash));
816 rc = oce_rss_itbl_init(sc, fwcmd);
818 mbx.u0.s.embedded = 1;
819 mbx.payload_length = sizeof(struct mbx_config_nic_rss);
820 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
822 rc = oce_mbox_post(sc, &mbx, NULL);
824 rc = fwcmd->hdr.u0.rsp.status;
826 device_printf(sc->dev,
827 "%s failed - cmd status: %d addi status: %d\n",
829 fwcmd->hdr.u0.rsp.additional_status);
835 * @brief RXF function to enable/disable device promiscuous mode
836 * @param sc software handle to the device
837 * @param enable enable/disable flag
838 * @returns 0 on success, EIO on failure
840 * The NIC_CONFIG_PROMISCUOUS command deprecated for Lancer.
841 * This function uses the COMMON_SET_IFACE_RX_FILTER command instead.
844 oce_rxf_set_promiscuous(POCE_SOFTC sc, uint8_t enable)
846 struct mbx_set_common_iface_rx_filter *fwcmd;
847 int sz = sizeof(struct mbx_set_common_iface_rx_filter);
848 iface_rx_filter_ctx_t *req;
852 /* allocate mbx payload's dma scatter/gather memory */
853 rc = oce_dma_alloc(sc, sz, &sgl, 0);
857 fwcmd = OCE_DMAPTR(&sgl, struct mbx_set_common_iface_rx_filter);
859 req = &fwcmd->params.req;
860 req->iface_flags_mask = MBX_RX_IFACE_FLAGS_PROMISCUOUS |
861 MBX_RX_IFACE_FLAGS_VLAN_PROMISCUOUS;
862 /* Bit 0 Mac promisc, Bit 1 Vlan promisc */
864 req->iface_flags = MBX_RX_IFACE_FLAGS_PROMISCUOUS;
867 req->iface_flags = MBX_RX_IFACE_FLAGS_VLAN_PROMISCUOUS;
869 req->if_id = sc->if_id;
871 rc = oce_set_common_iface_rx_filter(sc, &sgl);
872 oce_dma_free(sc, &sgl);
879 * @brief Function modify and select rx filter options
880 * @param sc software handle to the device
881 * @param sgl scatter/gather request/response
882 * @returns 0 on success, error code on failure
885 oce_set_common_iface_rx_filter(POCE_SOFTC sc, POCE_DMA_MEM sgl)
888 int mbx_sz = sizeof(struct mbx_set_common_iface_rx_filter);
889 struct mbx_set_common_iface_rx_filter *fwcmd;
892 bzero(&mbx, sizeof(struct oce_mbx));
893 fwcmd = OCE_DMAPTR(sgl, struct mbx_set_common_iface_rx_filter);
895 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
896 MBX_SUBSYSTEM_COMMON,
897 OPCODE_COMMON_SET_IFACE_RX_FILTER,
902 oce_dma_sync(sgl, BUS_DMASYNC_PREWRITE);
903 mbx.u0.s.embedded = 0;
904 mbx.u0.s.sge_count = 1;
905 mbx.payload.u0.u1.sgl[0].pa_lo = ADDR_LO(sgl->paddr);
906 mbx.payload.u0.u1.sgl[0].pa_hi = ADDR_HI(sgl->paddr);
907 mbx.payload.u0.u1.sgl[0].length = mbx_sz;
908 mbx.payload_length = mbx_sz;
909 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
911 rc = oce_mbox_post(sc, &mbx, NULL);
913 rc = fwcmd->hdr.u0.rsp.status;
915 device_printf(sc->dev,
916 "%s failed - cmd status: %d addi status: %d\n",
918 fwcmd->hdr.u0.rsp.additional_status);
923 * @brief Function to query the link status from the hardware
924 * @param sc software handle to the device
925 * @param[out] link pointer to the structure returning link attributes
926 * @returns 0 on success, EIO on failure
929 oce_get_link_status(POCE_SOFTC sc, struct link_status *link)
932 struct mbx_query_common_link_config *fwcmd;
935 bzero(&mbx, sizeof(struct oce_mbx));
937 IS_BE2(sc) ? (version = OCE_MBX_VER_V0) : (version = OCE_MBX_VER_V1);
939 fwcmd = (struct mbx_query_common_link_config *)&mbx.payload;
940 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
941 MBX_SUBSYSTEM_COMMON,
942 OPCODE_COMMON_QUERY_LINK_CONFIG,
944 sizeof(struct mbx_query_common_link_config),
947 mbx.u0.s.embedded = 1;
948 mbx.payload_length = sizeof(struct mbx_query_common_link_config);
949 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
951 rc = oce_mbox_post(sc, &mbx, NULL);
954 rc = fwcmd->hdr.u0.rsp.status;
956 device_printf(sc->dev,
957 "%s failed - cmd status: %d addi status: %d\n",
959 fwcmd->hdr.u0.rsp.additional_status);
962 /* interpret response */
963 link->qos_link_speed = HOST_16(fwcmd->params.rsp.qos_link_speed);
964 link->phys_port_speed = fwcmd->params.rsp.physical_port_speed;
965 link->logical_link_status = fwcmd->params.rsp.logical_link_status;
973 oce_mbox_get_nic_stats_v0(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem)
976 struct mbx_get_nic_stats_v0 *fwcmd;
979 bzero(&mbx, sizeof(struct oce_mbx));
981 fwcmd = OCE_DMAPTR(pstats_dma_mem, struct mbx_get_nic_stats_v0);
982 bzero(fwcmd, sizeof(struct mbx_get_nic_stats_v0));
984 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
988 sizeof(struct mbx_get_nic_stats_v0),
991 mbx.u0.s.embedded = 0;
992 mbx.u0.s.sge_count = 1;
994 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_PREWRITE);
996 mbx.payload.u0.u1.sgl[0].pa_lo = ADDR_LO(pstats_dma_mem->paddr);
997 mbx.payload.u0.u1.sgl[0].pa_hi = ADDR_HI(pstats_dma_mem->paddr);
998 mbx.payload.u0.u1.sgl[0].length = sizeof(struct mbx_get_nic_stats_v0);
1000 mbx.payload_length = sizeof(struct mbx_get_nic_stats_v0);
1002 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1004 rc = oce_mbox_post(sc, &mbx, NULL);
1006 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_POSTWRITE);
1009 rc = fwcmd->hdr.u0.rsp.status;
1011 device_printf(sc->dev,
1012 "%s failed - cmd status: %d addi status: %d\n",
1014 fwcmd->hdr.u0.rsp.additional_status);
1021 * @brief Function to get NIC statistics
1022 * @param sc software handle to the device
1023 * @param *stats pointer to where to store statistics
1024 * @param reset_stats resets statistics of set
1025 * @returns 0 on success, EIO on failure
1026 * @note command depricated in Lancer
1029 oce_mbox_get_nic_stats(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem)
1032 struct mbx_get_nic_stats *fwcmd;
1035 bzero(&mbx, sizeof(struct oce_mbx));
1036 fwcmd = OCE_DMAPTR(pstats_dma_mem, struct mbx_get_nic_stats);
1037 bzero(fwcmd, sizeof(struct mbx_get_nic_stats));
1039 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1043 sizeof(struct mbx_get_nic_stats),
1047 mbx.u0.s.embedded = 0; /* stats too large for embedded mbx rsp */
1048 mbx.u0.s.sge_count = 1; /* using scatter gather instead */
1050 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_PREWRITE);
1051 mbx.payload.u0.u1.sgl[0].pa_lo = ADDR_LO(pstats_dma_mem->paddr);
1052 mbx.payload.u0.u1.sgl[0].pa_hi = ADDR_HI(pstats_dma_mem->paddr);
1053 mbx.payload.u0.u1.sgl[0].length = sizeof(struct mbx_get_nic_stats);
1055 mbx.payload_length = sizeof(struct mbx_get_nic_stats);
1056 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1058 rc = oce_mbox_post(sc, &mbx, NULL);
1059 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_POSTWRITE);
1061 rc = fwcmd->hdr.u0.rsp.status;
1063 device_printf(sc->dev,
1064 "%s failed - cmd status: %d addi status: %d\n",
1066 fwcmd->hdr.u0.rsp.additional_status);
1072 * @brief Function to get pport (physical port) statistics
1073 * @param sc software handle to the device
1074 * @param *stats pointer to where to store statistics
1075 * @param reset_stats resets statistics of set
1076 * @returns 0 on success, EIO on failure
1079 oce_mbox_get_pport_stats(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem,
1080 uint32_t reset_stats)
1083 struct mbx_get_pport_stats *fwcmd;
1086 bzero(&mbx, sizeof(struct oce_mbx));
1087 fwcmd = OCE_DMAPTR(pstats_dma_mem, struct mbx_get_pport_stats);
1088 bzero(fwcmd, sizeof(struct mbx_get_pport_stats));
1090 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1092 NIC_GET_PPORT_STATS,
1094 sizeof(struct mbx_get_pport_stats),
1097 fwcmd->params.req.reset_stats = reset_stats;
1098 fwcmd->params.req.port_number = sc->port_id;
1100 mbx.u0.s.embedded = 0; /* stats too large for embedded mbx rsp */
1101 mbx.u0.s.sge_count = 1; /* using scatter gather instead */
1103 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_PREWRITE);
1104 mbx.payload.u0.u1.sgl[0].pa_lo = ADDR_LO(pstats_dma_mem->paddr);
1105 mbx.payload.u0.u1.sgl[0].pa_hi = ADDR_HI(pstats_dma_mem->paddr);
1106 mbx.payload.u0.u1.sgl[0].length = sizeof(struct mbx_get_pport_stats);
1108 mbx.payload_length = sizeof(struct mbx_get_pport_stats);
1109 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1111 rc = oce_mbox_post(sc, &mbx, NULL);
1112 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_POSTWRITE);
1115 rc = fwcmd->hdr.u0.rsp.status;
1117 device_printf(sc->dev,
1118 "%s failed - cmd status: %d addi status: %d\n",
1120 fwcmd->hdr.u0.rsp.additional_status);
1126 * @brief Function to get vport (virtual port) statistics
1127 * @param sc software handle to the device
1128 * @param *stats pointer to where to store statistics
1129 * @param reset_stats resets statistics of set
1130 * @returns 0 on success, EIO on failure
1133 oce_mbox_get_vport_stats(POCE_SOFTC sc, POCE_DMA_MEM pstats_dma_mem,
1134 uint32_t req_size, uint32_t reset_stats)
1137 struct mbx_get_vport_stats *fwcmd;
1140 bzero(&mbx, sizeof(struct oce_mbx));
1142 fwcmd = OCE_DMAPTR(pstats_dma_mem, struct mbx_get_vport_stats);
1143 bzero(fwcmd, sizeof(struct mbx_get_vport_stats));
1145 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1147 NIC_GET_VPORT_STATS,
1149 sizeof(struct mbx_get_vport_stats),
1152 fwcmd->params.req.reset_stats = reset_stats;
1153 fwcmd->params.req.vport_number = sc->if_id;
1155 mbx.u0.s.embedded = 0; /* stats too large for embedded mbx rsp */
1156 mbx.u0.s.sge_count = 1; /* using scatter gather instead */
1158 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_PREWRITE);
1159 mbx.payload.u0.u1.sgl[0].pa_lo = ADDR_LO(pstats_dma_mem->paddr);
1160 mbx.payload.u0.u1.sgl[0].pa_hi = ADDR_HI(pstats_dma_mem->paddr);
1161 mbx.payload.u0.u1.sgl[0].length = sizeof(struct mbx_get_vport_stats);
1163 mbx.payload_length = sizeof(struct mbx_get_vport_stats);
1164 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1166 rc = oce_mbox_post(sc, &mbx, NULL);
1167 oce_dma_sync(pstats_dma_mem, BUS_DMASYNC_POSTWRITE);
1170 rc = fwcmd->hdr.u0.rsp.status;
1172 device_printf(sc->dev,
1173 "%s failed - cmd status: %d addi status: %d\n",
1175 fwcmd->hdr.u0.rsp.additional_status);
1181 * @brief Function to update the muticast filter with
1183 * @param sc software handle to the device
1184 * @param dma_mem pointer to dma memory region
1185 * @returns 0 on success, EIO on failure
1188 oce_update_multicast(POCE_SOFTC sc, POCE_DMA_MEM pdma_mem)
1191 struct oce_mq_sge *sgl;
1192 struct mbx_set_common_iface_multicast *req = NULL;
1195 req = OCE_DMAPTR(pdma_mem, struct mbx_set_common_iface_multicast);
1196 mbx_common_req_hdr_init(&req->hdr, 0, 0,
1197 MBX_SUBSYSTEM_COMMON,
1198 OPCODE_COMMON_SET_IFACE_MULTICAST,
1200 sizeof(struct mbx_set_common_iface_multicast),
1203 bzero(&mbx, sizeof(struct oce_mbx));
1205 mbx.u0.s.embedded = 0; /*Non embeded*/
1206 mbx.payload_length = sizeof(struct mbx_set_common_iface_multicast);
1207 mbx.u0.s.sge_count = 1;
1208 sgl = &mbx.payload.u0.u1.sgl[0];
1209 sgl->pa_hi = htole32(upper_32_bits(pdma_mem->paddr));
1210 sgl->pa_lo = htole32((pdma_mem->paddr) & 0xFFFFFFFF);
1211 sgl->length = htole32(mbx.payload_length);
1213 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1215 rc = oce_mbox_post(sc, &mbx, NULL);
1217 rc = req->hdr.u0.rsp.status;
1219 device_printf(sc->dev,
1220 "%s failed - cmd status: %d addi status: %d\n",
1222 req->hdr.u0.rsp.additional_status);
1228 * @brief Function to send passthrough Ioctls
1229 * @param sc software handle to the device
1230 * @param dma_mem pointer to dma memory region
1231 * @param req_size size of dma_mem
1232 * @returns 0 on success, EIO on failure
1235 oce_pass_through_mbox(POCE_SOFTC sc, POCE_DMA_MEM dma_mem, uint32_t req_size)
1238 struct oce_mq_sge *sgl;
1241 bzero(&mbx, sizeof(struct oce_mbx));
1243 mbx.u0.s.embedded = 0; /*Non embeded*/
1244 mbx.payload_length = req_size;
1245 mbx.u0.s.sge_count = 1;
1246 sgl = &mbx.payload.u0.u1.sgl[0];
1247 sgl->pa_hi = htole32(upper_32_bits(dma_mem->paddr));
1248 sgl->pa_lo = htole32((dma_mem->paddr) & 0xFFFFFFFF);
1249 sgl->length = htole32(req_size);
1251 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1253 rc = oce_mbox_post(sc, &mbx, NULL);
1259 oce_mbox_macaddr_add(POCE_SOFTC sc, uint8_t *mac_addr,
1260 uint32_t if_id, uint32_t *pmac_id)
1263 struct mbx_add_common_iface_mac *fwcmd;
1266 bzero(&mbx, sizeof(struct oce_mbx));
1268 fwcmd = (struct mbx_add_common_iface_mac *)&mbx.payload;
1269 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1270 MBX_SUBSYSTEM_COMMON,
1271 OPCODE_COMMON_ADD_IFACE_MAC,
1273 sizeof(struct mbx_add_common_iface_mac),
1276 fwcmd->params.req.if_id = (uint16_t) if_id;
1277 bcopy(mac_addr, fwcmd->params.req.mac_address, 6);
1279 mbx.u0.s.embedded = 1;
1280 mbx.payload_length = sizeof(struct mbx_add_common_iface_mac);
1281 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1282 rc = oce_mbox_post(sc, &mbx, NULL);
1284 rc = fwcmd->hdr.u0.rsp.status;
1286 device_printf(sc->dev,
1287 "%s failed - cmd status: %d addi status: %d\n",
1289 fwcmd->hdr.u0.rsp.additional_status);
1292 *pmac_id = fwcmd->params.rsp.pmac_id;
1299 oce_mbox_macaddr_del(POCE_SOFTC sc, uint32_t if_id, uint32_t pmac_id)
1302 struct mbx_del_common_iface_mac *fwcmd;
1305 bzero(&mbx, sizeof(struct oce_mbx));
1307 fwcmd = (struct mbx_del_common_iface_mac *)&mbx.payload;
1308 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1309 MBX_SUBSYSTEM_COMMON,
1310 OPCODE_COMMON_DEL_IFACE_MAC,
1312 sizeof(struct mbx_del_common_iface_mac),
1315 fwcmd->params.req.if_id = (uint16_t)if_id;
1316 fwcmd->params.req.pmac_id = pmac_id;
1318 mbx.u0.s.embedded = 1;
1319 mbx.payload_length = sizeof(struct mbx_del_common_iface_mac);
1320 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1322 rc = oce_mbox_post(sc, &mbx, NULL);
1324 rc = fwcmd->hdr.u0.rsp.status;
1326 device_printf(sc->dev,
1327 "%s failed - cmd status: %d addi status: %d\n",
1329 fwcmd->hdr.u0.rsp.additional_status);
1336 oce_mbox_check_native_mode(POCE_SOFTC sc)
1339 struct mbx_common_set_function_cap *fwcmd;
1342 bzero(&mbx, sizeof(struct oce_mbx));
1344 fwcmd = (struct mbx_common_set_function_cap *)&mbx.payload;
1345 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1346 MBX_SUBSYSTEM_COMMON,
1347 OPCODE_COMMON_SET_FUNCTIONAL_CAPS,
1349 sizeof(struct mbx_common_set_function_cap),
1352 fwcmd->params.req.valid_capability_flags = CAP_SW_TIMESTAMPS |
1353 CAP_BE3_NATIVE_ERX_API;
1355 fwcmd->params.req.capability_flags = CAP_BE3_NATIVE_ERX_API;
1357 mbx.u0.s.embedded = 1;
1358 mbx.payload_length = sizeof(struct mbx_common_set_function_cap);
1359 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1361 rc = oce_mbox_post(sc, &mbx, NULL);
1363 rc = fwcmd->hdr.u0.rsp.status;
1365 device_printf(sc->dev,
1366 "%s failed - cmd status: %d addi status: %d\n",
1368 fwcmd->hdr.u0.rsp.additional_status);
1371 sc->be3_native = HOST_32(fwcmd->params.rsp.capability_flags)
1372 & CAP_BE3_NATIVE_ERX_API;
1381 oce_mbox_cmd_set_loopback(POCE_SOFTC sc, uint8_t port_num,
1382 uint8_t loopback_type, uint8_t enable)
1385 struct mbx_lowlevel_set_loopback_mode *fwcmd;
1389 bzero(&mbx, sizeof(struct oce_mbx));
1391 fwcmd = (struct mbx_lowlevel_set_loopback_mode *)&mbx.payload;
1392 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1393 MBX_SUBSYSTEM_LOWLEVEL,
1394 OPCODE_LOWLEVEL_SET_LOOPBACK_MODE,
1396 sizeof(struct mbx_lowlevel_set_loopback_mode),
1399 fwcmd->params.req.src_port = port_num;
1400 fwcmd->params.req.dest_port = port_num;
1401 fwcmd->params.req.loopback_type = loopback_type;
1402 fwcmd->params.req.loopback_state = enable;
1404 mbx.u0.s.embedded = 1;
1405 mbx.payload_length = sizeof(struct mbx_lowlevel_set_loopback_mode);
1406 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1408 rc = oce_mbox_post(sc, &mbx, NULL);
1410 rc = fwcmd->hdr.u0.rsp.status;
1412 device_printf(sc->dev,
1413 "%s failed - cmd status: %d addi status: %d\n",
1415 fwcmd->hdr.u0.rsp.additional_status);
1422 oce_mbox_cmd_test_loopback(POCE_SOFTC sc, uint32_t port_num,
1423 uint32_t loopback_type, uint32_t pkt_size, uint32_t num_pkts,
1428 struct mbx_lowlevel_test_loopback_mode *fwcmd;
1432 bzero(&mbx, sizeof(struct oce_mbx));
1434 fwcmd = (struct mbx_lowlevel_test_loopback_mode *)&mbx.payload;
1435 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1436 MBX_SUBSYSTEM_LOWLEVEL,
1437 OPCODE_LOWLEVEL_TEST_LOOPBACK,
1439 sizeof(struct mbx_lowlevel_test_loopback_mode),
1442 fwcmd->params.req.pattern = pattern;
1443 fwcmd->params.req.src_port = port_num;
1444 fwcmd->params.req.dest_port = port_num;
1445 fwcmd->params.req.pkt_size = pkt_size;
1446 fwcmd->params.req.num_pkts = num_pkts;
1447 fwcmd->params.req.loopback_type = loopback_type;
1449 mbx.u0.s.embedded = 1;
1450 mbx.payload_length = sizeof(struct mbx_lowlevel_test_loopback_mode);
1451 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1453 rc = oce_mbox_post(sc, &mbx, NULL);
1455 rc = fwcmd->hdr.u0.rsp.status;
1457 device_printf(sc->dev,
1458 "%s failed - cmd status: %d addi status: %d\n",
1460 fwcmd->hdr.u0.rsp.additional_status);
1466 oce_mbox_write_flashrom(POCE_SOFTC sc, uint32_t optype,uint32_t opcode,
1467 POCE_DMA_MEM pdma_mem, uint32_t num_bytes)
1471 struct oce_mq_sge *sgl = NULL;
1472 struct mbx_common_read_write_flashrom *fwcmd = NULL;
1473 int rc = 0, payload_len = 0;
1475 bzero(&mbx, sizeof(struct oce_mbx));
1476 fwcmd = OCE_DMAPTR(pdma_mem, struct mbx_common_read_write_flashrom);
1477 payload_len = sizeof(struct mbx_common_read_write_flashrom) + 32*1024;
1479 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1480 MBX_SUBSYSTEM_COMMON,
1481 OPCODE_COMMON_WRITE_FLASHROM,
1486 fwcmd->flash_op_type = LE_32(optype);
1487 fwcmd->flash_op_code = LE_32(opcode);
1488 fwcmd->data_buffer_size = LE_32(num_bytes);
1490 mbx.u0.s.embedded = 0; /*Non embeded*/
1491 mbx.payload_length = payload_len;
1492 mbx.u0.s.sge_count = 1;
1494 sgl = &mbx.payload.u0.u1.sgl[0];
1495 sgl->pa_hi = upper_32_bits(pdma_mem->paddr);
1496 sgl->pa_lo = pdma_mem->paddr & 0xFFFFFFFF;
1497 sgl->length = payload_len;
1499 /* post the command */
1500 rc = oce_mbox_post(sc, &mbx, NULL);
1502 rc = fwcmd->hdr.u0.rsp.status;
1504 device_printf(sc->dev,
1505 "%s failed - cmd status: %d addi status: %d\n",
1507 fwcmd->hdr.u0.rsp.additional_status);
1514 oce_mbox_get_flashrom_crc(POCE_SOFTC sc, uint8_t *flash_crc,
1515 uint32_t offset, uint32_t optype)
1518 int rc = 0, payload_len = 0;
1520 struct mbx_common_read_write_flashrom *fwcmd;
1522 bzero(&mbx, sizeof(struct oce_mbx));
1524 fwcmd = (struct mbx_common_read_write_flashrom *)&mbx.payload;
1526 /* Firmware requires extra 4 bytes with this ioctl. Since there
1527 is enough room in the mbx payload it should be good enough
1528 Reference: Bug 14853
1530 payload_len = sizeof(struct mbx_common_read_write_flashrom) + 4;
1532 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1533 MBX_SUBSYSTEM_COMMON,
1534 OPCODE_COMMON_READ_FLASHROM,
1539 fwcmd->flash_op_type = optype;
1540 fwcmd->flash_op_code = FLASHROM_OPER_REPORT;
1541 fwcmd->data_offset = offset;
1542 fwcmd->data_buffer_size = 0x4;
1544 mbx.u0.s.embedded = 1;
1545 mbx.payload_length = payload_len;
1547 /* post the command */
1548 rc = oce_mbox_post(sc, &mbx, NULL);
1550 rc = fwcmd->hdr.u0.rsp.status;
1552 device_printf(sc->dev,
1553 "%s failed - cmd status: %d addi status: %d\n",
1555 fwcmd->hdr.u0.rsp.additional_status);
1558 bcopy(fwcmd->data_buffer, flash_crc, 4);
1564 oce_mbox_get_phy_info(POCE_SOFTC sc, struct oce_phy_info *phy_info)
1568 struct mbx_common_phy_info *fwcmd;
1571 bzero(&mbx, sizeof(struct oce_mbx));
1573 fwcmd = (struct mbx_common_phy_info *)&mbx.payload;
1574 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1575 MBX_SUBSYSTEM_COMMON,
1576 OPCODE_COMMON_GET_PHY_CONFIG,
1578 sizeof(struct mbx_common_phy_info),
1581 mbx.u0.s.embedded = 1;
1582 mbx.payload_length = sizeof(struct mbx_common_phy_info);
1584 /* now post the command */
1585 rc = oce_mbox_post(sc, &mbx, NULL);
1587 rc = fwcmd->hdr.u0.rsp.status;
1589 device_printf(sc->dev,
1590 "%s failed - cmd status: %d addi status: %d\n",
1592 fwcmd->hdr.u0.rsp.additional_status);
1595 phy_info->phy_type = HOST_16(fwcmd->params.rsp.phy_info.phy_type);
1596 phy_info->interface_type =
1597 HOST_16(fwcmd->params.rsp.phy_info.interface_type);
1598 phy_info->auto_speeds_supported =
1599 HOST_16(fwcmd->params.rsp.phy_info.auto_speeds_supported);
1600 phy_info->fixed_speeds_supported =
1601 HOST_16(fwcmd->params.rsp.phy_info.fixed_speeds_supported);
1602 phy_info->misc_params = HOST_32(fwcmd->params.rsp.phy_info.misc_params);
1610 oce_mbox_lancer_write_flashrom(POCE_SOFTC sc, uint32_t data_size,
1611 uint32_t data_offset, POCE_DMA_MEM pdma_mem,
1612 uint32_t *written_data, uint32_t *additional_status)
1616 struct mbx_lancer_common_write_object *fwcmd = NULL;
1617 int rc = 0, payload_len = 0;
1619 bzero(&mbx, sizeof(struct oce_mbx));
1620 payload_len = sizeof(struct mbx_lancer_common_write_object);
1622 mbx.u0.s.embedded = 1;/* Embedded */
1623 mbx.payload_length = payload_len;
1624 fwcmd = (struct mbx_lancer_common_write_object *)&mbx.payload;
1626 /* initialize the ioctl header */
1627 mbx_common_req_hdr_init(&fwcmd->params.req.hdr, 0, 0,
1628 MBX_SUBSYSTEM_COMMON,
1629 OPCODE_COMMON_WRITE_OBJECT,
1634 fwcmd->params.req.write_length = data_size;
1636 fwcmd->params.req.eof = 1;
1638 fwcmd->params.req.eof = 0;
1640 strcpy(fwcmd->params.req.object_name, "/prg");
1641 fwcmd->params.req.descriptor_count = 1;
1642 fwcmd->params.req.write_offset = data_offset;
1643 fwcmd->params.req.buffer_length = data_size;
1644 fwcmd->params.req.address_lower = pdma_mem->paddr & 0xFFFFFFFF;
1645 fwcmd->params.req.address_upper = upper_32_bits(pdma_mem->paddr);
1647 /* post the command */
1648 rc = oce_mbox_post(sc, &mbx, NULL);
1650 rc = fwcmd->params.rsp.status;
1652 device_printf(sc->dev,
1653 "%s failed - cmd status: %d addi status: %d\n",
1655 fwcmd->params.rsp.additional_status);
1658 *written_data = HOST_32(fwcmd->params.rsp.actual_write_length);
1659 *additional_status = fwcmd->params.rsp.additional_status;
1668 oce_mbox_create_rq(struct oce_rq *rq)
1672 struct mbx_create_nic_rq *fwcmd;
1673 POCE_SOFTC sc = rq->parent;
1674 int rc, num_pages = 0;
1676 if (rq->qstate == QCREATED)
1679 bzero(&mbx, sizeof(struct oce_mbx));
1681 fwcmd = (struct mbx_create_nic_rq *)&mbx.payload;
1682 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1684 NIC_CREATE_RQ, MBX_TIMEOUT_SEC,
1685 sizeof(struct mbx_create_nic_rq),
1688 /* oce_page_list will also prepare pages */
1689 num_pages = oce_page_list(rq->ring, &fwcmd->params.req.pages[0]);
1692 fwcmd->params.req.frag_size = rq->cfg.frag_size/2048;
1693 fwcmd->params.req.page_size = 1;
1694 fwcmd->hdr.u0.req.version = OCE_MBX_VER_V1;
1696 fwcmd->params.req.frag_size = OCE_LOG2(rq->cfg.frag_size);
1697 fwcmd->params.req.num_pages = num_pages;
1698 fwcmd->params.req.cq_id = rq->cq->cq_id;
1699 fwcmd->params.req.if_id = sc->if_id;
1700 fwcmd->params.req.max_frame_size = rq->cfg.mtu;
1701 fwcmd->params.req.is_rss_queue = rq->cfg.is_rss_queue;
1703 mbx.u0.s.embedded = 1;
1704 mbx.payload_length = sizeof(struct mbx_create_nic_rq);
1706 rc = oce_mbox_post(sc, &mbx, NULL);
1708 rc = fwcmd->hdr.u0.rsp.status;
1710 device_printf(sc->dev,
1711 "%s failed - cmd status: %d addi status: %d\n",
1713 fwcmd->hdr.u0.rsp.additional_status);
1716 rq->rq_id = HOST_16(fwcmd->params.rsp.rq_id);
1717 rq->rss_cpuid = fwcmd->params.rsp.rss_cpuid;
1726 oce_mbox_create_wq(struct oce_wq *wq)
1729 struct mbx_create_nic_wq *fwcmd;
1730 POCE_SOFTC sc = wq->parent;
1731 int rc = 0, version, num_pages;
1733 bzero(&mbx, sizeof(struct oce_mbx));
1735 fwcmd = (struct mbx_create_nic_wq *)&mbx.payload;
1737 version = OCE_MBX_VER_V1;
1739 IS_PROFILE_SUPER_NIC(sc) ? (version = OCE_MBX_VER_V2)
1740 : (version = OCE_MBX_VER_V0);
1742 version = OCE_MBX_VER_V2;
1744 if (version > OCE_MBX_VER_V0)
1745 fwcmd->params.req.if_id = sc->if_id;
1747 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1749 NIC_CREATE_WQ, MBX_TIMEOUT_SEC,
1750 sizeof(struct mbx_create_nic_wq),
1753 num_pages = oce_page_list(wq->ring, &fwcmd->params.req.pages[0]);
1755 fwcmd->params.req.nic_wq_type = wq->cfg.wq_type;
1756 fwcmd->params.req.num_pages = num_pages;
1757 fwcmd->params.req.wq_size = OCE_LOG2(wq->cfg.q_len) + 1;
1758 fwcmd->params.req.cq_id = wq->cq->cq_id;
1759 fwcmd->params.req.ulp_num = 1;
1761 mbx.u0.s.embedded = 1;
1762 mbx.payload_length = sizeof(struct mbx_create_nic_wq);
1764 rc = oce_mbox_post(sc, &mbx, NULL);
1766 rc = fwcmd->hdr.u0.rsp.status;
1768 device_printf(sc->dev,
1769 "%s failed - cmd status: %d addi status: %d\n",
1771 fwcmd->hdr.u0.rsp.additional_status);
1774 wq->wq_id = HOST_16(fwcmd->params.rsp.wq_id);
1775 if (version == OCE_MBX_VER_V2)
1776 wq->db_offset = HOST_32(fwcmd->params.rsp.db_offset);
1778 wq->db_offset = PD_TXULP_DB;
1787 oce_mbox_create_eq(struct oce_eq *eq)
1790 struct mbx_create_common_eq *fwcmd;
1791 POCE_SOFTC sc = eq->parent;
1795 bzero(&mbx, sizeof(struct oce_mbx));
1797 fwcmd = (struct mbx_create_common_eq *)&mbx.payload;
1799 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1800 MBX_SUBSYSTEM_COMMON,
1801 OPCODE_COMMON_CREATE_EQ, MBX_TIMEOUT_SEC,
1802 sizeof(struct mbx_create_common_eq),
1805 num_pages = oce_page_list(eq->ring, &fwcmd->params.req.pages[0]);
1806 fwcmd->params.req.ctx.num_pages = num_pages;
1807 fwcmd->params.req.ctx.valid = 1;
1808 fwcmd->params.req.ctx.size = (eq->eq_cfg.item_size == 4) ? 0 : 1;
1809 fwcmd->params.req.ctx.count = OCE_LOG2(eq->eq_cfg.q_len / 256);
1810 fwcmd->params.req.ctx.armed = 0;
1811 fwcmd->params.req.ctx.delay_mult = eq->eq_cfg.cur_eqd;
1814 mbx.u0.s.embedded = 1;
1815 mbx.payload_length = sizeof(struct mbx_create_common_eq);
1817 rc = oce_mbox_post(sc, &mbx, NULL);
1819 rc = fwcmd->hdr.u0.rsp.status;
1821 device_printf(sc->dev,
1822 "%s failed - cmd status: %d addi status: %d\n",
1824 fwcmd->hdr.u0.rsp.additional_status);
1827 eq->eq_id = HOST_16(fwcmd->params.rsp.eq_id);
1835 oce_mbox_cq_create(struct oce_cq *cq, uint32_t ncoalesce, uint32_t is_eventable)
1838 struct mbx_create_common_cq *fwcmd;
1839 POCE_SOFTC sc = cq->parent;
1842 uint32_t num_pages, page_size;
1846 bzero(&mbx, sizeof(struct oce_mbx));
1848 fwcmd = (struct mbx_create_common_cq *)&mbx.payload;
1851 version = OCE_MBX_VER_V2;
1853 version = OCE_MBX_VER_V0;
1855 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1856 MBX_SUBSYSTEM_COMMON,
1857 OPCODE_COMMON_CREATE_CQ,
1859 sizeof(struct mbx_create_common_cq),
1862 ctx = &fwcmd->params.req.cq_ctx;
1864 num_pages = oce_page_list(cq->ring, &fwcmd->params.req.pages[0]);
1865 page_size = 1; /* 1 for 4K */
1867 if (version == OCE_MBX_VER_V2) {
1868 ctx->v2.num_pages = LE_16(num_pages);
1869 ctx->v2.page_size = page_size;
1870 ctx->v2.eventable = is_eventable;
1872 ctx->v2.count = OCE_LOG2(cq->cq_cfg.q_len / 256);
1873 ctx->v2.nodelay = cq->cq_cfg.nodelay;
1874 ctx->v2.coalesce_wm = ncoalesce;
1876 ctx->v2.eq_id = cq->eq->eq_id;
1877 if (ctx->v2.count == 3) {
1878 if ((u_int)cq->cq_cfg.q_len > (4*1024)-1)
1879 ctx->v2.cqe_count = (4*1024)-1;
1881 ctx->v2.cqe_count = cq->cq_cfg.q_len;
1884 ctx->v0.num_pages = LE_16(num_pages);
1885 ctx->v0.eventable = is_eventable;
1887 ctx->v0.count = OCE_LOG2(cq->cq_cfg.q_len / 256);
1888 ctx->v0.nodelay = cq->cq_cfg.nodelay;
1889 ctx->v0.coalesce_wm = ncoalesce;
1891 ctx->v0.eq_id = cq->eq->eq_id;
1894 mbx.u0.s.embedded = 1;
1895 mbx.payload_length = sizeof(struct mbx_create_common_cq);
1897 rc = oce_mbox_post(sc, &mbx, NULL);
1899 rc = fwcmd->hdr.u0.rsp.status;
1901 device_printf(sc->dev,
1902 "%s failed - cmd status: %d addi status: %d\n",
1904 fwcmd->hdr.u0.rsp.additional_status);
1907 cq->cq_id = HOST_16(fwcmd->params.rsp.cq_id);
1914 oce_mbox_read_transrecv_data(POCE_SOFTC sc, uint32_t page_num)
1918 struct mbx_read_common_transrecv_data *fwcmd;
1919 struct oce_mq_sge *sgl;
1922 /* Allocate DMA mem*/
1923 if (oce_dma_alloc(sc, sizeof(struct mbx_read_common_transrecv_data),
1927 fwcmd = OCE_DMAPTR(&dma, struct mbx_read_common_transrecv_data);
1928 bzero(fwcmd, sizeof(struct mbx_read_common_transrecv_data));
1930 bzero(&mbx, sizeof(struct oce_mbx));
1931 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1932 MBX_SUBSYSTEM_COMMON,
1933 OPCODE_COMMON_READ_TRANSRECEIVER_DATA,
1935 sizeof(struct mbx_read_common_transrecv_data),
1938 /* fill rest of mbx */
1939 mbx.u0.s.embedded = 0;
1940 mbx.payload_length = sizeof(struct mbx_read_common_transrecv_data);
1941 mbx.u0.s.sge_count = 1;
1942 sgl = &mbx.payload.u0.u1.sgl[0];
1943 sgl->pa_hi = htole32(upper_32_bits(dma.paddr));
1944 sgl->pa_lo = htole32((dma.paddr) & 0xFFFFFFFF);
1945 sgl->length = htole32(mbx.payload_length);
1946 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
1948 fwcmd->params.req.port = LE_32(sc->port_id);
1949 fwcmd->params.req.page_num = LE_32(page_num);
1952 rc = oce_mbox_post(sc, &mbx, NULL);
1954 rc = fwcmd->hdr.u0.rsp.status;
1956 device_printf(sc->dev,
1957 "%s failed - cmd status: %d addi status: %d\n",
1959 fwcmd->hdr.u0.rsp.additional_status);
1962 if(fwcmd->params.rsp.page_num == PAGE_NUM_A0)
1964 bcopy((char *)fwcmd->params.rsp.page_data,
1965 (char *)&sfp_vpd_dump_buffer[0],
1966 TRANSCEIVER_A0_SIZE);
1969 if(fwcmd->params.rsp.page_num == PAGE_NUM_A2)
1971 bcopy((char *)fwcmd->params.rsp.page_data,
1972 (char *)&sfp_vpd_dump_buffer[32],
1973 TRANSCEIVER_A2_SIZE);
1976 oce_dma_free(sc, &dma);
1981 oce_mbox_eqd_modify_periodic(POCE_SOFTC sc, struct oce_set_eqd *set_eqd,
1985 struct mbx_modify_common_eq_delay *fwcmd;
1989 bzero(&mbx, sizeof(struct oce_mbx));
1991 /* Initialize MODIFY_EQ_DELAY ioctl header */
1992 fwcmd = (struct mbx_modify_common_eq_delay *)&mbx.payload;
1993 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
1994 MBX_SUBSYSTEM_COMMON,
1995 OPCODE_COMMON_MODIFY_EQ_DELAY,
1997 sizeof(struct mbx_modify_common_eq_delay),
1999 /* fill rest of mbx */
2000 mbx.u0.s.embedded = 1;
2001 mbx.payload_length = sizeof(struct mbx_modify_common_eq_delay);
2002 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
2004 fwcmd->params.req.num_eq = num;
2005 for (i = 0; i < num; i++) {
2006 fwcmd->params.req.delay[i].eq_id =
2007 htole32(set_eqd[i].eq_id);
2008 fwcmd->params.req.delay[i].phase = 0;
2009 fwcmd->params.req.delay[i].dm =
2010 htole32(set_eqd[i].delay_multiplier);
2015 rc = oce_mbox_post(sc, &mbx, NULL);
2018 rc = fwcmd->hdr.u0.rsp.status;
2020 device_printf(sc->dev,
2021 "%s failed - cmd status: %d addi status: %d\n",
2023 fwcmd->hdr.u0.rsp.additional_status);
2027 oce_get_profile_config(POCE_SOFTC sc, uint32_t max_rss)
2030 struct mbx_common_get_profile_config *fwcmd;
2033 struct oce_mq_sge *sgl;
2035 uint32_t desc_count = 0;
2036 struct oce_nic_resc_desc *nic_desc = NULL;
2038 boolean_t nic_desc_valid = FALSE;
2043 /* Allocate DMA mem*/
2044 if (oce_dma_alloc(sc, sizeof(struct mbx_common_get_profile_config),
2048 /* Initialize MODIFY_EQ_DELAY ioctl header */
2049 fwcmd = OCE_DMAPTR(&dma, struct mbx_common_get_profile_config);
2050 bzero(fwcmd, sizeof(struct mbx_common_get_profile_config));
2053 version = OCE_MBX_VER_V1;
2055 version = OCE_MBX_VER_V0;
2057 bzero(&mbx, sizeof(struct oce_mbx));
2058 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
2059 MBX_SUBSYSTEM_COMMON,
2060 OPCODE_COMMON_GET_PROFILE_CONFIG,
2062 sizeof(struct mbx_common_get_profile_config),
2064 /* fill rest of mbx */
2065 mbx.u0.s.embedded = 0;
2066 mbx.payload_length = sizeof(struct mbx_common_get_profile_config);
2067 mbx.u0.s.sge_count = 1;
2068 sgl = &mbx.payload.u0.u1.sgl[0];
2069 sgl->pa_hi = htole32(upper_32_bits(dma.paddr));
2070 sgl->pa_lo = htole32((dma.paddr) & 0xFFFFFFFF);
2071 sgl->length = htole32(mbx.payload_length);
2072 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
2074 fwcmd->params.req.type = ACTIVE_PROFILE;
2077 rc = oce_mbox_post(sc, &mbx, NULL);
2079 rc = fwcmd->hdr.u0.rsp.status;
2081 device_printf(sc->dev,
2082 "%s failed - cmd status: %d addi status: %d\n",
2084 fwcmd->hdr.u0.rsp.additional_status);
2088 nic_desc = (struct oce_nic_resc_desc *) fwcmd->params.rsp.resources;
2089 desc_count = HOST_32(fwcmd->params.rsp.desc_count);
2090 for (i = 0; i < desc_count; i++) {
2091 if ((nic_desc->desc_type == NIC_RESC_DESC_TYPE_V0) ||
2092 (nic_desc->desc_type == NIC_RESC_DESC_TYPE_V1)) {
2093 nic_desc_valid = TRUE;
2096 nic_desc = (struct oce_nic_resc_desc *) \
2097 ((char *)nic_desc + nic_desc->desc_len);
2099 if (!nic_desc_valid) {
2104 sc->max_vlans = HOST_16(nic_desc->vlan_count);
2105 sc->nwqs = HOST_16(nic_desc->txq_count);
2107 sc->nwqs = MIN(sc->nwqs, OCE_MAX_WQ);
2109 sc->nwqs = OCE_MAX_WQ;
2111 sc->nrssqs = HOST_16(nic_desc->rssq_count);
2113 sc->nrssqs = MIN(sc->nrssqs, max_rss);
2115 sc->nrssqs = max_rss;
2116 sc->nrqs = sc->nrssqs + 1; /* 1 for def RX */;
2120 oce_dma_free(sc, &dma);
2126 oce_get_func_config(POCE_SOFTC sc)
2129 struct mbx_common_get_func_config *fwcmd;
2132 struct oce_mq_sge *sgl;
2134 uint32_t desc_count = 0;
2135 struct oce_nic_resc_desc *nic_desc = NULL;
2137 boolean_t nic_desc_valid = FALSE;
2138 uint32_t max_rss = 0;
2140 if ((IS_BE(sc) || IS_SH(sc)) && (!sc->be3_native))
2141 max_rss = OCE_LEGACY_MODE_RSS;
2143 max_rss = OCE_MAX_RSS;
2145 /* Allocate DMA mem*/
2146 if (oce_dma_alloc(sc, sizeof(struct mbx_common_get_func_config),
2150 /* Initialize MODIFY_EQ_DELAY ioctl header */
2151 fwcmd = OCE_DMAPTR(&dma, struct mbx_common_get_func_config);
2152 bzero(fwcmd, sizeof(struct mbx_common_get_func_config));
2155 version = OCE_MBX_VER_V1;
2157 version = OCE_MBX_VER_V0;
2159 bzero(&mbx, sizeof(struct oce_mbx));
2160 mbx_common_req_hdr_init(&fwcmd->hdr, 0, 0,
2161 MBX_SUBSYSTEM_COMMON,
2162 OPCODE_COMMON_GET_FUNCTION_CONFIG,
2164 sizeof(struct mbx_common_get_func_config),
2166 /* fill rest of mbx */
2167 mbx.u0.s.embedded = 0;
2168 mbx.payload_length = sizeof(struct mbx_common_get_func_config);
2169 mbx.u0.s.sge_count = 1;
2170 sgl = &mbx.payload.u0.u1.sgl[0];
2171 sgl->pa_hi = htole32(upper_32_bits(dma.paddr));
2172 sgl->pa_lo = htole32((dma.paddr) & 0xFFFFFFFF);
2173 sgl->length = htole32(mbx.payload_length);
2174 DW_SWAP(u32ptr(&mbx), mbx.payload_length + OCE_BMBX_RHDR_SZ);
2177 rc = oce_mbox_post(sc, &mbx, NULL);
2179 rc = fwcmd->hdr.u0.rsp.status;
2181 device_printf(sc->dev,
2182 "%s failed - cmd status: %d addi status: %d\n",
2184 fwcmd->hdr.u0.rsp.additional_status);
2188 nic_desc = (struct oce_nic_resc_desc *) fwcmd->params.rsp.resources;
2189 desc_count = HOST_32(fwcmd->params.rsp.desc_count);
2190 for (i = 0; i < desc_count; i++) {
2191 if ((nic_desc->desc_type == NIC_RESC_DESC_TYPE_V0) ||
2192 (nic_desc->desc_type == NIC_RESC_DESC_TYPE_V1)) {
2193 nic_desc_valid = TRUE;
2196 nic_desc = (struct oce_nic_resc_desc *) \
2197 ((char *)nic_desc + nic_desc->desc_len);
2199 if (!nic_desc_valid) {
2204 sc->max_vlans = nic_desc->vlan_count;
2205 sc->nwqs = HOST_32(nic_desc->txq_count);
2207 sc->nwqs = MIN(sc->nwqs, OCE_MAX_WQ);
2209 sc->nwqs = OCE_MAX_WQ;
2211 sc->nrssqs = HOST_32(nic_desc->rssq_count);
2213 sc->nrssqs = MIN(sc->nrssqs, max_rss);
2215 sc->nrssqs = max_rss;
2216 sc->nrqs = sc->nrssqs + 1; /* 1 for def RX */;
2219 oce_dma_free(sc, &dma);