2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2013-2016 Qlogic Corporation
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
32 * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
41 #include "ql_inline.h"
46 static void qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp,
50 qla_rcv_error(qla_host_t *ha)
53 QL_INITIATE_RECOVERY(ha);
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;
73 lro = &ha->hw.sds[sds_idx].lro;
75 if (ha->hw.num_rds_rings > 1)
78 ha->hw.rds[r_idx].count++;
80 sdsp = &ha->hw.sds[sds_idx];
81 rx_ring = &ha->rx_ring[r_idx];
83 for (i = 0; i < sgc->num_handles; i++) {
84 rxb = &rx_ring->rx_buf[sgc->handle[i] & 0x7FFF];
86 QL_ASSERT(ha, (rxb != NULL),
87 ("%s: [sds_idx]=[%d] rxb != NULL\n", __func__,\
90 if ((rxb == NULL) || QL_ERR_INJECT(ha, INJCT_RX_RXB_INVAL)) {
92 device_printf(ha->pci_dev,
93 "%s invalid rxb[%d, %d, 0x%04x]\n",
94 __func__, sds_idx, i, sgc->handle[i]);
103 QL_ASSERT(ha, (mp != NULL),
104 ("%s: [sds_idx]=[%d] mp != NULL\n", __func__,\
107 bus_dmamap_sync(ha->rx_tag, rxb->map, BUS_DMASYNC_POSTREAD);
110 rxb->next = sdsp->rxb_free;
111 sdsp->rxb_free = rxb;
114 if ((mp == NULL) || QL_ERR_INJECT(ha, INJCT_RX_MP_NULL)) {
116 device_printf(ha->pci_dev,
117 "%s mp == NULL [%d, %d, 0x%04x]\n",
118 __func__, sds_idx, i, sgc->handle[i]);
125 mp->m_flags |= M_PKTHDR;
126 mp->m_pkthdr.len = sgc->pkt_length;
127 mp->m_pkthdr.rcvif = ifp;
128 rem_len = mp->m_pkthdr.len;
130 mp->m_flags &= ~M_PKTHDR;
133 rem_len = rem_len - mp->m_len;
137 mpl->m_len = rem_len;
139 eh = mtod(mpf, struct ether_vlan_header *);
141 if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
142 uint32_t *data = (uint32_t *)eh;
144 mpf->m_pkthdr.ether_vtag = ntohs(eh->evl_tag);
145 mpf->m_flags |= M_VLANTAG;
147 *(data + 3) = *(data + 2);
148 *(data + 2) = *(data + 1);
151 m_adj(mpf, ETHER_VLAN_ENCAP_LEN);
154 if (sgc->chksum_status == Q8_STAT_DESC_STATUS_CHKSUM_OK) {
155 mpf->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID |
156 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
157 mpf->m_pkthdr.csum_data = 0xFFFF;
159 mpf->m_pkthdr.csum_flags = 0;
162 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
164 mpf->m_pkthdr.flowid = sgc->rss_hash;
166 #if __FreeBSD_version >= 1100000
167 M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE_HASH);
169 #if (__FreeBSD_version >= 903511 && __FreeBSD_version < 1100000)
170 M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE);
172 M_HASHTYPE_SET(mpf, M_HASHTYPE_NONE);
174 #endif /* #if __FreeBSD_version >= 1100000 */
176 if (ha->hw.enable_soft_lro) {
177 #if (__FreeBSD_version >= 1100101)
179 tcp_lro_queue_mbuf(lro, mpf);
182 if (tcp_lro_rx(lro, mpf, 0))
183 (*ifp->if_input)(ifp, mpf);
185 #endif /* #if (__FreeBSD_version >= 1100101) */
188 (*ifp->if_input)(ifp, mpf);
191 if (sdsp->rx_free > ha->std_replenish)
192 qla_replenish_normal_rx(ha, sdsp, r_idx);
197 #define QLA_TCP_HDR_SIZE 20
198 #define QLA_TCP_TS_OPTION_SIZE 12
202 * Function: Handles normal ethernet frames received
205 qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx)
208 struct mbuf *mp = NULL, *mpf = NULL, *mpl = NULL;
209 struct ifnet *ifp = ha->ifp;
211 struct ether_vlan_header *eh;
212 uint32_t i, rem_len = 0, pkt_length, iplen;
214 struct ip *ip = NULL;
215 struct ip6_hdr *ip6 = NULL;
218 qla_rx_ring_t *rx_ring;
220 if (ha->hw.num_rds_rings > 1)
223 ha->hw.rds[r_idx].count++;
225 rx_ring = &ha->rx_ring[r_idx];
227 ha->hw.rds[r_idx].lro_pkt_count++;
229 sdsp = &ha->hw.sds[sds_idx];
231 pkt_length = sgc->payload_length + sgc->l4_offset;
233 if (sgc->flags & Q8_LRO_COMP_TS) {
234 pkt_length += QLA_TCP_HDR_SIZE + QLA_TCP_TS_OPTION_SIZE;
236 pkt_length += QLA_TCP_HDR_SIZE;
238 ha->hw.rds[r_idx].lro_bytes += pkt_length;
240 for (i = 0; i < sgc->num_handles; i++) {
241 rxb = &rx_ring->rx_buf[sgc->handle[i] & 0x7FFF];
243 QL_ASSERT(ha, (rxb != NULL),
244 ("%s: [sds_idx]=[%d] rxb != NULL\n", __func__,\
247 if ((rxb == NULL) || QL_ERR_INJECT(ha, INJCT_LRO_RXB_INVAL)) {
249 device_printf(ha->pci_dev,
250 "%s invalid rxb[%d, %d, 0x%04x]\n",
251 __func__, sds_idx, i, sgc->handle[i]);
260 QL_ASSERT(ha, (mp != NULL),
261 ("%s: [sds_idx]=[%d] mp != NULL\n", __func__,\
264 bus_dmamap_sync(ha->rx_tag, rxb->map, BUS_DMASYNC_POSTREAD);
267 rxb->next = sdsp->rxb_free;
268 sdsp->rxb_free = rxb;
271 if ((mp == NULL) || QL_ERR_INJECT(ha, INJCT_LRO_MP_NULL)) {
273 device_printf(ha->pci_dev,
274 "%s mp == NULL [%d, %d, 0x%04x]\n",
275 __func__, sds_idx, i, sgc->handle[i]);
282 mp->m_flags |= M_PKTHDR;
283 mp->m_pkthdr.len = pkt_length;
284 mp->m_pkthdr.rcvif = ifp;
285 rem_len = mp->m_pkthdr.len;
287 mp->m_flags &= ~M_PKTHDR;
290 rem_len = rem_len - mp->m_len;
294 mpl->m_len = rem_len;
296 th = (struct tcphdr *)(mpf->m_data + sgc->l4_offset);
298 if (sgc->flags & Q8_LRO_COMP_PUSH_BIT)
299 th->th_flags |= TH_PUSH;
301 m_adj(mpf, sgc->l2_offset);
303 eh = mtod(mpf, struct ether_vlan_header *);
305 if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
306 uint32_t *data = (uint32_t *)eh;
308 mpf->m_pkthdr.ether_vtag = ntohs(eh->evl_tag);
309 mpf->m_flags |= M_VLANTAG;
311 *(data + 3) = *(data + 2);
312 *(data + 2) = *(data + 1);
315 m_adj(mpf, ETHER_VLAN_ENCAP_LEN);
317 etype = ntohs(eh->evl_proto);
319 etype = ntohs(eh->evl_encap_proto);
322 if (etype == ETHERTYPE_IP) {
323 ip = (struct ip *)(mpf->m_data + ETHER_HDR_LEN);
325 iplen = (ip->ip_hl << 2) + (th->th_off << 2) +
328 ip->ip_len = htons(iplen);
332 M_HASHTYPE_SET(mpf, M_HASHTYPE_RSS_TCP_IPV4);
334 } else if (etype == ETHERTYPE_IPV6) {
335 ip6 = (struct ip6_hdr *)(mpf->m_data + ETHER_HDR_LEN);
337 iplen = (th->th_off << 2) + sgc->payload_length;
339 ip6->ip6_plen = htons(iplen);
343 M_HASHTYPE_SET(mpf, M_HASHTYPE_RSS_TCP_IPV6);
348 if (sdsp->rx_free > ha->std_replenish)
349 qla_replenish_normal_rx(ha, sdsp, r_idx);
353 mpf->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID |
354 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
355 mpf->m_pkthdr.csum_data = 0xFFFF;
357 mpf->m_pkthdr.flowid = sgc->rss_hash;
359 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
361 (*ifp->if_input)(ifp, mpf);
363 if (sdsp->rx_free > ha->std_replenish)
364 qla_replenish_normal_rx(ha, sdsp, r_idx);
370 qla_rcv_cont_sds(qla_host_t *ha, uint32_t sds_idx, uint32_t comp_idx,
371 uint32_t dcount, uint16_t *handle, uint16_t *nhandles)
374 uint16_t num_handles;
375 q80_stat_desc_t *sdesc;
381 for (i = 0; i < dcount; i++) {
382 comp_idx = (comp_idx + 1) & (NUM_STATUS_DESCRIPTORS-1);
383 sdesc = (q80_stat_desc_t *)
384 &ha->hw.sds[sds_idx].sds_ring_base[comp_idx];
386 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
388 if (!opcode || QL_ERR_INJECT(ha, INJCT_INV_CONT_OPCODE)) {
389 device_printf(ha->pci_dev, "%s: opcode=0 %p %p\n",
390 __func__, (void *)sdesc->data[0],
391 (void *)sdesc->data[1]);
395 num_handles = Q8_SGL_STAT_DESC_NUM_HANDLES((sdesc->data[1]));
397 device_printf(ha->pci_dev, "%s: opcode=0 %p %p\n",
398 __func__, (void *)sdesc->data[0],
399 (void *)sdesc->data[1]);
403 if (QL_ERR_INJECT(ha, INJCT_NUM_HNDLE_INVALID))
406 switch (num_handles) {
408 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
412 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
413 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
417 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
418 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
419 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
423 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
424 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
425 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
426 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
430 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
431 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
432 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
433 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
434 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
438 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
439 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
440 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
441 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
442 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
443 *handle++ = Q8_SGL_STAT_DESC_HANDLE6((sdesc->data[1]));
447 *handle++ = Q8_SGL_STAT_DESC_HANDLE1((sdesc->data[0]));
448 *handle++ = Q8_SGL_STAT_DESC_HANDLE2((sdesc->data[0]));
449 *handle++ = Q8_SGL_STAT_DESC_HANDLE3((sdesc->data[0]));
450 *handle++ = Q8_SGL_STAT_DESC_HANDLE4((sdesc->data[0]));
451 *handle++ = Q8_SGL_STAT_DESC_HANDLE5((sdesc->data[1]));
452 *handle++ = Q8_SGL_STAT_DESC_HANDLE6((sdesc->data[1]));
453 *handle++ = Q8_SGL_STAT_DESC_HANDLE7((sdesc->data[1]));
457 device_printf(ha->pci_dev,
458 "%s: invalid num handles %p %p\n",
459 __func__, (void *)sdesc->data[0],
460 (void *)sdesc->data[1]);
463 ("%s: %s [nh, sds, d0, d1]=[%d, %d, %p, %p]\n",
464 __func__, "invalid num handles", sds_idx, num_handles,
465 (void *)sdesc->data[0],(void *)sdesc->data[1]));
470 *nhandles = *nhandles + num_handles;
477 * Function: Main Interrupt Service Routine
480 ql_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
484 uint32_t comp_idx, c_idx = 0, desc_count = 0, opcode;
485 volatile q80_stat_desc_t *sdesc, *sdesc0 = NULL;
489 uint32_t sds_replenish_threshold = 0;
496 hw->sds[sds_idx].rcv_active = 1;
498 hw->sds[sds_idx].rcv_active = 0;
502 QL_DPRINT2(ha, (dev, "%s: [%d]enter\n", __func__, sds_idx));
507 comp_idx = hw->sds[sds_idx].sdsr_next;
509 while (count-- && !ha->stop_rcv) {
510 sdesc = (q80_stat_desc_t *)
511 &hw->sds[sds_idx].sds_ring_base[comp_idx];
513 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
519 case Q8_STAT_DESC_OPCODE_RCV_PKT:
523 bzero(&sgc, sizeof(qla_sgl_comp_t));
526 Q8_STAT_DESC_TOTAL_LENGTH((sdesc->data[0]));
527 sgc.rcv.num_handles = 1;
529 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
530 sgc.rcv.chksum_status =
531 Q8_STAT_DESC_STATUS((sdesc->data[1]));
534 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
536 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
538 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
540 qla_rx_intr(ha, &sgc.rcv, sds_idx);
543 case Q8_STAT_DESC_OPCODE_SGL_RCV:
546 Q8_STAT_DESC_COUNT_SGL_RCV((sdesc->data[1]));
548 if (desc_count > 1) {
549 c_idx = (comp_idx + desc_count -1) &
550 (NUM_STATUS_DESCRIPTORS-1);
551 sdesc0 = (q80_stat_desc_t *)
552 &hw->sds[sds_idx].sds_ring_base[c_idx];
554 if ((Q8_STAT_DESC_OPCODE((sdesc0->data[1])) !=
555 Q8_STAT_DESC_OPCODE_CONT) ||
556 QL_ERR_INJECT(ha, INJCT_SGL_RCV_INV_DESC_COUNT)) {
562 bzero(&sgc, sizeof(qla_sgl_comp_t));
565 Q8_STAT_DESC_TOTAL_LENGTH_SGL_RCV(\
567 sgc.rcv.chksum_status =
568 Q8_STAT_DESC_STATUS((sdesc->data[1]));
571 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
573 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
575 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
578 QL_ASSERT(ha, (desc_count <= 2) ,\
579 ("%s: [sds_idx, data0, data1]="\
580 "%d, %p, %p]\n", __func__, sds_idx,\
581 (void *)sdesc->data[0],\
582 (void *)sdesc->data[1]));
584 sgc.rcv.num_handles = 1;
586 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
588 if (qla_rcv_cont_sds(ha, sds_idx, comp_idx, desc_count,
589 &sgc.rcv.handle[1], &nhandles)) {
591 "%s: [sds_idx, dcount, data0, data1]="
592 "[%d, %d, 0x%llx, 0x%llx]\n",
593 __func__, sds_idx, desc_count,
594 (long long unsigned int)sdesc->data[0],
595 (long long unsigned int)sdesc->data[1]);
600 sgc.rcv.num_handles += nhandles;
602 qla_rx_intr(ha, &sgc.rcv, sds_idx);
606 case Q8_STAT_DESC_OPCODE_SGL_LRO:
609 Q8_STAT_DESC_COUNT_SGL_LRO((sdesc->data[1]));
611 if (desc_count > 1) {
612 c_idx = (comp_idx + desc_count -1) &
613 (NUM_STATUS_DESCRIPTORS-1);
614 sdesc0 = (q80_stat_desc_t *)
615 &hw->sds[sds_idx].sds_ring_base[c_idx];
617 if ((Q8_STAT_DESC_OPCODE((sdesc0->data[1])) !=
618 Q8_STAT_DESC_OPCODE_CONT) ||
619 QL_ERR_INJECT(ha, INJCT_SGL_LRO_INV_DESC_COUNT)) {
624 bzero(&sgc, sizeof(qla_sgl_comp_t));
626 sgc.lro.payload_length =
627 Q8_STAT_DESC_TOTAL_LENGTH_SGL_RCV((sdesc->data[0]));
630 Q8_STAT_DESC_RSS_HASH((sdesc->data[0]));
632 sgc.lro.num_handles = 1;
634 Q8_STAT_DESC_HANDLE((sdesc->data[0]));
636 if (Q8_SGL_LRO_STAT_TS((sdesc->data[1])))
637 sgc.lro.flags |= Q8_LRO_COMP_TS;
639 if (Q8_SGL_LRO_STAT_PUSH_BIT((sdesc->data[1])))
640 sgc.lro.flags |= Q8_LRO_COMP_PUSH_BIT;
643 Q8_SGL_LRO_STAT_L2_OFFSET((sdesc->data[1]));
645 Q8_SGL_LRO_STAT_L4_OFFSET((sdesc->data[1]));
647 if (Q8_STAT_DESC_VLAN((sdesc->data[1]))) {
649 Q8_STAT_DESC_VLAN_ID((sdesc->data[1]));
652 QL_ASSERT(ha, (desc_count <= 7) ,\
653 ("%s: [sds_idx, data0, data1]="\
654 "[%d, 0x%llx, 0x%llx]\n",\
656 (long long unsigned int)sdesc->data[0],\
657 (long long unsigned int)sdesc->data[1]));
659 if (qla_rcv_cont_sds(ha, sds_idx, comp_idx,
660 desc_count, &sgc.lro.handle[1], &nhandles)) {
662 "%s: [sds_idx, data0, data1]="\
663 "[%d, 0x%llx, 0x%llx]\n",\
665 (long long unsigned int)sdesc->data[0],\
666 (long long unsigned int)sdesc->data[1]);
672 sgc.lro.num_handles += nhandles;
674 if (qla_lro_intr(ha, &sgc.lro, sds_idx)) {
676 "%s: [sds_idx, data0, data1]="\
677 "[%d, 0x%llx, 0x%llx]\n",\
679 (long long unsigned int)sdesc->data[0],\
680 (long long unsigned int)sdesc->data[1]);
682 "%s: [comp_idx, c_idx, dcount, nhndls]="\
683 "[%d, %d, %d, %d]\n",\
684 __func__, comp_idx, c_idx, desc_count,
685 sgc.lro.num_handles);
686 if (desc_count > 1) {
688 "%s: [sds_idx, data0, data1]="\
689 "[%d, 0x%llx, 0x%llx]\n",\
691 (long long unsigned int)sdesc0->data[0],\
692 (long long unsigned int)sdesc0->data[1]);
700 device_printf(dev, "%s: default 0x%llx!\n", __func__,
701 (long long unsigned int)sdesc->data[0]);
708 sds_replenish_threshold += desc_count;
710 while (desc_count--) {
711 sdesc->data[0] = 0ULL;
712 sdesc->data[1] = 0ULL;
713 comp_idx = (comp_idx + 1) & (NUM_STATUS_DESCRIPTORS-1);
714 sdesc = (q80_stat_desc_t *)
715 &hw->sds[sds_idx].sds_ring_base[comp_idx];
718 if (sds_replenish_threshold > ha->hw.sds_cidx_thres) {
719 sds_replenish_threshold = 0;
720 if (hw->sds[sds_idx].sdsr_next != comp_idx) {
721 QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx,\
724 hw->sds[sds_idx].sdsr_next = comp_idx;
728 if (ha->hw.enable_soft_lro) {
729 struct lro_ctrl *lro;
731 lro = &ha->hw.sds[sds_idx].lro;
733 #if (__FreeBSD_version >= 1100101)
735 tcp_lro_flush_all(lro);
738 struct lro_entry *queued;
740 while ((!SLIST_EMPTY(&lro->lro_active))) {
741 queued = SLIST_FIRST(&lro->lro_active);
742 SLIST_REMOVE_HEAD(&lro->lro_active, next);
743 tcp_lro_flush(lro, queued);
746 #endif /* #if (__FreeBSD_version >= 1100101) */
750 goto ql_rcv_isr_exit;
752 if (hw->sds[sds_idx].sdsr_next != comp_idx) {
753 QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx);
754 hw->sds[sds_idx].sdsr_next = comp_idx;
756 if (ha->hw.num_rds_rings > 1)
759 sdsp = &ha->hw.sds[sds_idx];
761 if (sdsp->rx_free > ha->std_replenish)
762 qla_replenish_normal_rx(ha, sdsp, r_idx);
765 sdesc = (q80_stat_desc_t *)&hw->sds[sds_idx].sds_ring_base[comp_idx];
766 opcode = Q8_STAT_DESC_OPCODE((sdesc->data[1]));
772 hw->sds[sds_idx].rcv_active = 0;
778 ql_mbx_isr(void *arg)
782 uint32_t prev_link_state;
787 printf("%s: arg == NULL\n", __func__);
791 data = READ_REG32(ha, Q8_FW_MBOX_CNTRL);
792 if ((data & 0x3) != 0x1) {
793 WRITE_REG32(ha, ha->hw.mbx_intr_mask_offset, 0);
797 data = READ_REG32(ha, Q8_FW_MBOX0);
799 if ((data & 0xF000) != 0x8000)
802 data = data & 0xFFFF;
805 case 0x8001: /* It's an AEN */
807 ha->hw.cable_oui = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
809 data = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
810 ha->hw.cable_length = data & 0xFFFF;
813 ha->hw.link_speed = data & 0xFFF;
815 data = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
817 prev_link_state = ha->hw.link_up;
819 data = (((data & 0xFF) == 0) ? 0 : 1);
820 atomic_store_rel_8(&ha->hw.link_up, (uint8_t)data);
822 device_printf(ha->pci_dev,
823 "%s: AEN[0x8001] data = 0x%08x, prev_link_state = 0x%08x\n",
824 __func__, data, prev_link_state);
826 if (prev_link_state != ha->hw.link_up) {
828 if_link_state_change(ha->ifp, LINK_STATE_UP);
830 if_link_state_change(ha->ifp, LINK_STATE_DOWN);
833 ha->hw.module_type = ((data >> 8) & 0xFF);
834 ha->hw.fduplex = (((data & 0xFF0000) == 0) ? 0 : 1);
835 ha->hw.autoneg = (((data & 0xFF000000) == 0) ? 0 : 1);
837 data = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
838 ha->hw.loopback_mode = data & 0x03;
840 ha->hw.link_faults = (data >> 3) & 0xFF;
845 device_printf(ha->pci_dev, "%s: AEN[0x%08x]\n", __func__, data);
851 ha->hw.aen_mb0 = 0x8101;
852 ha->hw.aen_mb1 = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
853 ha->hw.aen_mb2 = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
854 ha->hw.aen_mb3 = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
855 ha->hw.aen_mb4 = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
856 device_printf(ha->pci_dev, "%s: AEN[0x%08x 0x%08x 0x%08x 0%08x 0x%08x]\n",
857 __func__, data, ha->hw.aen_mb1, ha->hw.aen_mb2,
858 ha->hw.aen_mb3, ha->hw.aen_mb4);
862 /* for now just dump the registers */
866 ombx[0] = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
867 ombx[1] = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
868 ombx[2] = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
869 ombx[3] = READ_REG32(ha, (Q8_FW_MBOX0 + 16));
870 ombx[4] = READ_REG32(ha, (Q8_FW_MBOX0 + 20));
872 device_printf(ha->pci_dev, "%s: "
873 "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
874 __func__, data, ombx[0], ombx[1], ombx[2],
881 /* sfp insertion aen */
882 device_printf(ha->pci_dev, "%s: sfp inserted [0x%08x]\n",
883 __func__, READ_REG32(ha, (Q8_FW_MBOX0 + 4)));
887 /* sfp removal aen */
888 device_printf(ha->pci_dev, "%s: sfp removed]\n", __func__);
895 ombx[0] = READ_REG32(ha, (Q8_FW_MBOX0 + 4));
896 ombx[1] = READ_REG32(ha, (Q8_FW_MBOX0 + 8));
897 ombx[2] = READ_REG32(ha, (Q8_FW_MBOX0 + 12));
899 device_printf(ha->pci_dev, "%s: "
900 "0x%08x 0x%08x 0x%08x 0x%08x \n",
901 __func__, data, ombx[0], ombx[1], ombx[2]);
906 device_printf(ha->pci_dev, "%s: AEN[0x%08x]\n", __func__, data);
909 WRITE_REG32(ha, Q8_FW_MBOX_CNTRL, 0x0);
910 WRITE_REG32(ha, ha->hw.mbx_intr_mask_offset, 0x0);
915 qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp, uint32_t r_idx)
918 int count = sdsp->rx_free;
922 /* we can play with this value via a sysctl */
923 uint32_t replenish_thresh = ha->hw.rds_pidx_thres;
925 rdesc = &ha->hw.rds[r_idx];
927 rx_next = rdesc->rx_next;
930 rxb = sdsp->rxb_free;
935 sdsp->rxb_free = rxb->next;
938 if (ql_get_mbuf(ha, rxb, NULL) == 0) {
939 qla_set_hw_rcv_desc(ha, r_idx, rdesc->rx_in,
941 rxb->paddr, (rxb->m_head)->m_pkthdr.len);
943 if (rdesc->rx_in == NUM_RX_DESCRIPTORS)
946 if (rdesc->rx_next == NUM_RX_DESCRIPTORS)
949 device_printf(ha->pci_dev,
950 "%s: qla_get_mbuf [(%d),(%d),(%d)] failed\n",
951 __func__, r_idx, rdesc->rx_in, rxb->handle);
954 rxb->next = sdsp->rxb_free;
955 sdsp->rxb_free = rxb;
960 if (replenish_thresh-- == 0) {
961 QL_UPDATE_RDS_PRODUCER_INDEX(ha, rdesc->prod_std,
963 rx_next = rdesc->rx_next;
964 replenish_thresh = ha->hw.rds_pidx_thres;
968 if (rx_next != rdesc->rx_next) {
969 QL_UPDATE_RDS_PRODUCER_INDEX(ha, rdesc->prod_std,
977 qla_ivec_t *ivec = arg;
988 if ((idx = ivec->sds_idx) >= ha->hw.num_sds_rings)
991 fp = &ha->tx_fp[idx];
992 hw->sds[idx].intr_count++;
994 if ((fp->fp_taskqueue != NULL) &&
995 (ifp->if_drv_flags & IFF_DRV_RUNNING))
996 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);