2 * Copyright (c) 2013-2016 Qlogic Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, 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 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
30 * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
40 #include "ql_inline.h"
45 static void qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp,
49 qla_rcv_error(qla_host_t *ha)
51 ha->flags.stop_rcv = 1;
52 ha->qla_initiate_recovery = 1;
58 * Function: Handles normal ethernet frames received
61 qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx)
64 struct mbuf *mp = NULL, *mpf = NULL, *mpl = NULL;
65 struct ifnet *ifp = ha->ifp;
67 struct ether_vlan_header *eh;
68 uint32_t i, rem_len = 0;
70 qla_rx_ring_t *rx_ring;
72 if (ha->hw.num_rds_rings > 1)
75 ha->hw.rds[r_idx].count++;
77 sdsp = &ha->hw.sds[sds_idx];
78 rx_ring = &ha->rx_ring[r_idx];
80 for (i = 0; i < sgc->num_handles; i++) {
81 rxb = &rx_ring->rx_buf[sgc->handle[i] & 0x7FFF];
83 QL_ASSERT(ha, (rxb != NULL),
84 ("%s: [sds_idx]=[%d] rxb != NULL\n", __func__,\
87 if ((rxb == NULL) || QL_ERR_INJECT(ha, INJCT_RX_RXB_INVAL)) {
89 device_printf(ha->pci_dev,
90 "%s invalid rxb[%d, %d, 0x%04x]\n",
91 __func__, sds_idx, i, sgc->handle[i]);
100 QL_ASSERT(ha, (mp != NULL),
101 ("%s: [sds_idx]=[%d] mp != NULL\n", __func__,\
104 bus_dmamap_sync(ha->rx_tag, rxb->map, BUS_DMASYNC_POSTREAD);
107 rxb->next = sdsp->rxb_free;
108 sdsp->rxb_free = rxb;
111 if ((mp == NULL) || QL_ERR_INJECT(ha, INJCT_RX_MP_NULL)) {
113 device_printf(ha->pci_dev,
114 "%s mp == NULL [%d, %d, 0x%04x]\n",
115 __func__, sds_idx, i, sgc->handle[i]);
122 mp->m_flags |= M_PKTHDR;
123 mp->m_pkthdr.len = sgc->pkt_length;
124 mp->m_pkthdr.rcvif = ifp;
125 rem_len = mp->m_pkthdr.len;
127 mp->m_flags &= ~M_PKTHDR;
130 rem_len = rem_len - mp->m_len;
134 mpl->m_len = rem_len;
136 eh = mtod(mpf, struct ether_vlan_header *);
138 if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
139 uint32_t *data = (uint32_t *)eh;
141 mpf->m_pkthdr.ether_vtag = ntohs(eh->evl_tag);
142 mpf->m_flags |= M_VLANTAG;
144 *(data + 3) = *(data + 2);
145 *(data + 2) = *(data + 1);
148 m_adj(mpf, ETHER_VLAN_ENCAP_LEN);
151 if (sgc->chksum_status == Q8_STAT_DESC_STATUS_CHKSUM_OK) {
152 mpf->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID |
153 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
154 mpf->m_pkthdr.csum_data = 0xFFFF;
156 mpf->m_pkthdr.csum_flags = 0;
159 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
161 mpf->m_pkthdr.flowid = sgc->rss_hash;
163 #if __FreeBSD_version >= 1100000
164 M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE_HASH);
166 M_HASHTYPE_SET(mpf, M_HASHTYPE_NONE);
167 #endif /* #if __FreeBSD_version >= 1100000 */
169 (*ifp->if_input)(ifp, mpf);
171 if (sdsp->rx_free > ha->std_replenish)
172 qla_replenish_normal_rx(ha, sdsp, r_idx);
177 #define QLA_TCP_HDR_SIZE 20
178 #define QLA_TCP_TS_OPTION_SIZE 12
182 * Function: Handles normal ethernet frames received
185 qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx)
188 struct mbuf *mp = NULL, *mpf = NULL, *mpl = NULL;
189 struct ifnet *ifp = ha->ifp;
191 struct ether_vlan_header *eh;
192 uint32_t i, rem_len = 0, pkt_length, iplen;
194 struct ip *ip = NULL;
195 struct ip6_hdr *ip6 = NULL;
198 qla_rx_ring_t *rx_ring;
200 if (ha->hw.num_rds_rings > 1)
203 ha->hw.rds[r_idx].count++;
205 rx_ring = &ha->rx_ring[r_idx];
209 sdsp = &ha->hw.sds[sds_idx];
211 pkt_length = sgc->payload_length + sgc->l4_offset;
213 if (sgc->flags & Q8_LRO_COMP_TS) {
214 pkt_length += QLA_TCP_HDR_SIZE + QLA_TCP_TS_OPTION_SIZE;
216 pkt_length += QLA_TCP_HDR_SIZE;
218 ha->lro_bytes += pkt_length;
220 for (i = 0; i < sgc->num_handles; i++) {
221 rxb = &rx_ring->rx_buf[sgc->handle[i] & 0x7FFF];
223 QL_ASSERT(ha, (rxb != NULL),
224 ("%s: [sds_idx]=[%d] rxb != NULL\n", __func__,\
227 if ((rxb == NULL) || QL_ERR_INJECT(ha, INJCT_LRO_RXB_INVAL)) {
229 device_printf(ha->pci_dev,
230 "%s invalid rxb[%d, %d, 0x%04x]\n",
231 __func__, sds_idx, i, sgc->handle[i]);
240 QL_ASSERT(ha, (mp != NULL),
241 ("%s: [sds_idx]=[%d] mp != NULL\n", __func__,\
244 bus_dmamap_sync(ha->rx_tag, rxb->map, BUS_DMASYNC_POSTREAD);
247 rxb->next = sdsp->rxb_free;
248 sdsp->rxb_free = rxb;
251 if ((mp == NULL) || QL_ERR_INJECT(ha, INJCT_LRO_MP_NULL)) {
253 device_printf(ha->pci_dev,
254 "%s mp == NULL [%d, %d, 0x%04x]\n",
255 __func__, sds_idx, i, sgc->handle[i]);
262 mp->m_flags |= M_PKTHDR;
263 mp->m_pkthdr.len = pkt_length;
264 mp->m_pkthdr.rcvif = ifp;
265 rem_len = mp->m_pkthdr.len;
267 mp->m_flags &= ~M_PKTHDR;
270 rem_len = rem_len - mp->m_len;
274 mpl->m_len = rem_len;
276 th = (struct tcphdr *)(mpf->m_data + sgc->l4_offset);
278 if (sgc->flags & Q8_LRO_COMP_PUSH_BIT)
279 th->th_flags |= TH_PUSH;
281 m_adj(mpf, sgc->l2_offset);
283 eh = mtod(mpf, struct ether_vlan_header *);
285 if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
286 uint32_t *data = (uint32_t *)eh;
288 mpf->m_pkthdr.ether_vtag = ntohs(eh->evl_tag);
289 mpf->m_flags |= M_VLANTAG;
291 *(data + 3) = *(data + 2);
292 *(data + 2) = *(data + 1);
295 m_adj(mpf, ETHER_VLAN_ENCAP_LEN);
297 etype = ntohs(eh->evl_proto);
299 etype = ntohs(eh->evl_encap_proto);
302 if (etype == ETHERTYPE_IP) {
303 ip = (struct ip *)(mpf->m_data + ETHER_HDR_LEN);
305 iplen = (ip->ip_hl << 2) + (th->th_off << 2) +
308 ip->ip_len = htons(iplen);
312 M_HASHTYPE_SET(mpf, M_HASHTYPE_RSS_TCP_IPV4);
314 } else if (etype == ETHERTYPE_IPV6) {
315 ip6 = (struct ip6_hdr *)(mpf->m_data + ETHER_HDR_LEN);
317 iplen = (th->th_off << 2) + sgc->payload_length;
319 ip6->ip6_plen = htons(iplen);
323 M_HASHTYPE_SET(mpf, M_HASHTYPE_RSS_TCP_IPV6);
328 if (sdsp->rx_free > ha->std_replenish)
329 qla_replenish_normal_rx(ha, sdsp, r_idx);
333 mpf->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID |
334 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
335 mpf->m_pkthdr.csum_data = 0xFFFF;
337 mpf->m_pkthdr.flowid = sgc->rss_hash;
339 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
341 (*ifp->if_input)(ifp, mpf);
343 if (sdsp->rx_free > ha->std_replenish)
344 qla_replenish_normal_rx(ha, sdsp, r_idx);
350 qla_rcv_cont_sds(qla_host_t *ha, uint32_t sds_idx, uint32_t comp_idx,
351 uint32_t dcount, uint16_t *handle, uint16_t *nhandles)
354 uint16_t num_handles;
355 q80_stat_desc_t *sdesc;
361 for (i = 0; i < dcount; i++) {
362 comp_idx = (comp_idx + 1) & (NUM_STATUS_DESCRIPTORS-1);
363 sdesc = (q80_stat_desc_t *)
364 &ha->hw.sds[sds_idx].sds_ring_base[comp_idx];
366 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
369 device_printf(ha->pci_dev, "%s: opcode=0 %p %p\n",
370 __func__, (void *)sdesc->data[0],
371 (void *)sdesc->data[1]);
375 num_handles = Q8_SGL_STAT_DESC_NUM_HANDLES((sdesc->data[1]));
377 device_printf(ha->pci_dev, "%s: opcode=0 %p %p\n",
378 __func__, (void *)sdesc->data[0],
379 (void *)sdesc->data[1]);
383 if (QL_ERR_INJECT(ha, INJCT_NUM_HNDLE_INVALID))
386 switch (num_handles) {
389 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
393 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
394 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
398 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
399 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
400 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
404 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
405 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
406 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
407 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
411 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
412 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
413 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
414 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
415 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
419 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
420 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
421 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
422 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
423 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
424 *handle++ = Q8_SGL_STAT_DESC_HANDLE6((sdesc->data[1]));
428 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
429 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
430 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
431 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
432 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
433 *handle++ = Q8_SGL_STAT_DESC_HANDLE6((sdesc->data[1]));
434 *handle++ = Q8_SGL_STAT_DESC_HANDLE7((sdesc->data[1]));
438 device_printf(ha->pci_dev,
439 "%s: invalid num handles %p %p\n",
440 __func__, (void *)sdesc->data[0],
441 (void *)sdesc->data[1]);
444 ("%s: %s [nh, sds, d0, d1]=[%d, %d, %p, %p]\n",
445 __func__, "invalid num handles", sds_idx, num_handles,
446 (void *)sdesc->data[0],(void *)sdesc->data[1]));
451 *nhandles = *nhandles + num_handles;
458 * Function: Main Interrupt Service Routine
461 ql_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
465 uint32_t comp_idx, c_idx = 0, desc_count = 0, opcode;
466 volatile q80_stat_desc_t *sdesc, *sdesc0 = NULL;
470 uint32_t sds_replenish_threshold = 0;
477 hw->sds[sds_idx].rcv_active = 1;
478 if (ha->flags.stop_rcv) {
479 hw->sds[sds_idx].rcv_active = 0;
483 QL_DPRINT2(ha, (dev, "%s: [%d]enter\n", __func__, sds_idx));
488 comp_idx = hw->sds[sds_idx].sdsr_next;
490 while (count-- && !ha->flags.stop_rcv) {
492 sdesc = (q80_stat_desc_t *)
493 &hw->sds[sds_idx].sds_ring_base[comp_idx];
495 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
500 hw->sds[sds_idx].intr_count++;
503 case Q8_STAT_DESC_OPCODE_RCV_PKT:
507 bzero(&sgc, sizeof(qla_sgl_comp_t));
510 Q8_STAT_DESC_TOTAL_LENGTH((sdesc->data[0]));
511 sgc.rcv.num_handles = 1;
513 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
514 sgc.rcv.chksum_status =
515 Q8_STAT_DESC_STATUS((sdesc->data[1]));
518 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
520 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
522 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
524 qla_rx_intr(ha, &sgc.rcv, sds_idx);
527 case Q8_STAT_DESC_OPCODE_SGL_RCV:
530 Q8_STAT_DESC_COUNT_SGL_RCV((sdesc->data[1]));
532 if (desc_count > 1) {
533 c_idx = (comp_idx + desc_count -1) &
534 (NUM_STATUS_DESCRIPTORS-1);
535 sdesc0 = (q80_stat_desc_t *)
536 &hw->sds[sds_idx].sds_ring_base[c_idx];
538 if (Q8_STAT_DESC_OPCODE((sdesc0->data[1])) !=
539 Q8_STAT_DESC_OPCODE_CONT) {
545 bzero(&sgc, sizeof(qla_sgl_comp_t));
548 Q8_STAT_DESC_TOTAL_LENGTH_SGL_RCV(\
550 sgc.rcv.chksum_status =
551 Q8_STAT_DESC_STATUS((sdesc->data[1]));
554 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
556 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
558 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
561 QL_ASSERT(ha, (desc_count <= 2) ,\
562 ("%s: [sds_idx, data0, data1]="\
563 "%d, %p, %p]\n", __func__, sds_idx,\
564 (void *)sdesc->data[0],\
565 (void *)sdesc->data[1]));
567 sgc.rcv.num_handles = 1;
569 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
571 if (qla_rcv_cont_sds(ha, sds_idx, comp_idx, desc_count,
572 &sgc.rcv.handle[1], &nhandles)) {
574 "%s: [sds_idx, dcount, data0, data1]="
575 "[%d, %d, 0x%llx, 0x%llx]\n",
576 __func__, sds_idx, desc_count,
577 (long long unsigned int)sdesc->data[0],
578 (long long unsigned int)sdesc->data[1]);
583 sgc.rcv.num_handles += nhandles;
585 qla_rx_intr(ha, &sgc.rcv, sds_idx);
589 case Q8_STAT_DESC_OPCODE_SGL_LRO:
592 Q8_STAT_DESC_COUNT_SGL_LRO((sdesc->data[1]));
594 if (desc_count > 1) {
595 c_idx = (comp_idx + desc_count -1) &
596 (NUM_STATUS_DESCRIPTORS-1);
597 sdesc0 = (q80_stat_desc_t *)
598 &hw->sds[sds_idx].sds_ring_base[c_idx];
600 if (Q8_STAT_DESC_OPCODE((sdesc0->data[1])) !=
601 Q8_STAT_DESC_OPCODE_CONT) {
606 bzero(&sgc, sizeof(qla_sgl_comp_t));
608 sgc.lro.payload_length =
609 Q8_STAT_DESC_TOTAL_LENGTH_SGL_RCV((sdesc->data[0]));
612 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
614 sgc.lro.num_handles = 1;
616 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
618 if (Q8_SGL_LRO_STAT_TS((sdesc->data[1])))
619 sgc.lro.flags |= Q8_LRO_COMP_TS;
621 if (Q8_SGL_LRO_STAT_PUSH_BIT((sdesc->data[1])))
622 sgc.lro.flags |= Q8_LRO_COMP_PUSH_BIT;
625 Q8_SGL_LRO_STAT_L2_OFFSET((sdesc->data[1]));
627 Q8_SGL_LRO_STAT_L4_OFFSET((sdesc->data[1]));
629 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
631 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
634 QL_ASSERT(ha, (desc_count <= 7) ,\
635 ("%s: [sds_idx, data0, data1]="\
636 "[%d, 0x%llx, 0x%llx]\n",\
638 (long long unsigned int)sdesc->data[0],\
639 (long long unsigned int)sdesc->data[1]));
641 if (qla_rcv_cont_sds(ha, sds_idx, comp_idx,
642 desc_count, &sgc.lro.handle[1], &nhandles)) {
644 "%s: [sds_idx, data0, data1]="\
645 "[%d, 0x%llx, 0x%llx]\n",\
647 (long long unsigned int)sdesc->data[0],\
648 (long long unsigned int)sdesc->data[1]);
654 sgc.lro.num_handles += nhandles;
656 if (qla_lro_intr(ha, &sgc.lro, sds_idx)) {
658 "%s: [sds_idx, data0, data1]="\
659 "[%d, 0x%llx, 0x%llx]\n",\
661 (long long unsigned int)sdesc->data[0],\
662 (long long unsigned int)sdesc->data[1]);
664 "%s: [comp_idx, c_idx, dcount, nhndls]="\
665 "[%d, %d, %d, %d]\n",\
666 __func__, comp_idx, c_idx, desc_count,
667 sgc.lro.num_handles);
668 if (desc_count > 1) {
670 "%s: [sds_idx, data0, data1]="\
671 "[%d, 0x%llx, 0x%llx]\n",\
673 (long long unsigned int)sdesc0->data[0],\
674 (long long unsigned int)sdesc0->data[1]);
681 device_printf(dev, "%s: default 0x%llx!\n", __func__,
682 (long long unsigned int)sdesc->data[0]);
689 sds_replenish_threshold += desc_count;
692 while (desc_count--) {
693 sdesc->data[0] = 0ULL;
694 sdesc->data[1] = 0ULL;
695 comp_idx = (comp_idx + 1) & (NUM_STATUS_DESCRIPTORS-1);
696 sdesc = (q80_stat_desc_t *)
697 &hw->sds[sds_idx].sds_ring_base[comp_idx];
700 if (sds_replenish_threshold > ha->hw.sds_cidx_thres) {
701 sds_replenish_threshold = 0;
702 if (hw->sds[sds_idx].sdsr_next != comp_idx) {
703 QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx,\
706 hw->sds[sds_idx].sdsr_next = comp_idx;
710 if (ha->flags.stop_rcv)
711 goto ql_rcv_isr_exit;
713 if (hw->sds[sds_idx].sdsr_next != comp_idx) {
714 QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx);
715 hw->sds[sds_idx].sdsr_next = comp_idx;
717 hw->sds[sds_idx].spurious_intr_count++;
719 if (ha->hw.num_rds_rings > 1)
722 sdsp = &ha->hw.sds[sds_idx];
724 if (sdsp->rx_free > ha->std_replenish)
725 qla_replenish_normal_rx(ha, sdsp, r_idx);
728 sdesc = (q80_stat_desc_t *)&hw->sds[sds_idx].sds_ring_base[comp_idx];
729 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
735 hw->sds[sds_idx].rcv_active = 0;
741 ql_mbx_isr(void *arg)
745 uint32_t prev_link_state;
750 device_printf(ha->pci_dev, "%s: arg == NULL\n", __func__);
754 data = READ_REG32(ha, Q8_FW_MBOX_CNTRL);
755 if ((data & 0x3) != 0x1) {
756 WRITE_REG32(ha, ha->hw.mbx_intr_mask_offset, 0);
760 data = READ_REG32(ha, Q8_FW_MBOX0);
762 if ((data & 0xF000) != 0x8000)
765 data = data & 0xFFFF;
769 case 0x8001: /* It's an AEN */
771 ha->hw.cable_oui = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
773 data = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
774 ha->hw.cable_length = data & 0xFFFF;
777 ha->hw.link_speed = data & 0xFFF;
779 data = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
781 prev_link_state = ha->hw.link_up;
782 ha->hw.link_up = (((data & 0xFF) == 0) ? 0 : 1);
784 if (prev_link_state != ha->hw.link_up) {
786 if_link_state_change(ha->ifp, LINK_STATE_UP);
788 if_link_state_change(ha->ifp, LINK_STATE_DOWN);
792 ha->hw.module_type = ((data >> 8) & 0xFF);
793 ha->hw.flags.fduplex = (((data & 0xFF0000) == 0) ? 0 : 1);
794 ha->hw.flags.autoneg = (((data & 0xFF000000) == 0) ? 0 : 1);
796 data = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
797 ha->hw.flags.loopback_mode = data & 0x03;
799 ha->hw.link_faults = (data >> 3) & 0xFF;
809 ha->hw.aen_mb0 = 0x8101;
810 ha->hw.aen_mb1 = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
811 ha->hw.aen_mb2 = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
812 ha->hw.aen_mb3 = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
813 ha->hw.aen_mb4 = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
817 /* for now just dump the registers */
821 ombx[0] = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
822 ombx[1] = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
823 ombx[2] = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
824 ombx[3] = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
825 ombx[4] = READ_REG32(ha, (Q8_FW_MBOX0 + 20));
827 device_printf(ha->pci_dev, "%s: "
828 "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
829 __func__, data, ombx[0], ombx[1], ombx[2],
836 /* sfp insertion aen */
837 device_printf(ha->pci_dev, "%s: sfp inserted [0x%08x]\n",
838 __func__, READ_REG32(ha, (Q8_FW_MBOX0 + 4)));
842 /* sfp removal aen */
843 device_printf(ha->pci_dev, "%s: sfp removed]\n", __func__);
850 ombx[0] = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
851 ombx[1] = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
852 ombx[2] = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
854 device_printf(ha->pci_dev, "%s: "
855 "0x%08x 0x%08x 0x%08x 0x%08x \n",
856 __func__, data, ombx[0], ombx[1], ombx[2]);
861 device_printf(ha->pci_dev, "%s: AEN[0x%08x]\n", __func__, data);
864 WRITE_REG32(ha, Q8_FW_MBOX_CNTRL, 0x0);
865 WRITE_REG32(ha, ha->hw.mbx_intr_mask_offset, 0x0);
871 qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp, uint32_t r_idx)
874 int count = sdsp->rx_free;
878 /* we can play with this value via a sysctl */
879 uint32_t replenish_thresh = ha->hw.rds_pidx_thres;
881 rdesc = &ha->hw.rds[r_idx];
883 rx_next = rdesc->rx_next;
886 rxb = sdsp->rxb_free;
891 sdsp->rxb_free = rxb->next;
894 if (ql_get_mbuf(ha, rxb, NULL) == 0) {
895 qla_set_hw_rcv_desc(ha, r_idx, rdesc->rx_in,
897 rxb->paddr, (rxb->m_head)->m_pkthdr.len);
899 if (rdesc->rx_in == NUM_RX_DESCRIPTORS)
902 if (rdesc->rx_next == NUM_RX_DESCRIPTORS)
905 device_printf(ha->pci_dev,
906 "%s: qla_get_mbuf [(%d),(%d),(%d)] failed\n",
907 __func__, r_idx, rdesc->rx_in, rxb->handle);
910 rxb->next = sdsp->rxb_free;
911 sdsp->rxb_free = rxb;
916 if (replenish_thresh-- == 0) {
917 QL_UPDATE_RDS_PRODUCER_INDEX(ha, rdesc->prod_std,
919 rx_next = rdesc->rx_next;
920 replenish_thresh = ha->hw.rds_pidx_thres;
924 if (rx_next != rdesc->rx_next) {
925 QL_UPDATE_RDS_PRODUCER_INDEX(ha, rdesc->prod_std,
933 qla_ivec_t *ivec = arg;
944 if ((idx = ivec->sds_idx) >= ha->hw.num_sds_rings)
948 fp = &ha->tx_fp[idx];
950 if (fp->fp_taskqueue != NULL)
951 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);