Lines Matching refs:sq

699 	struct snd_queue *sq;
703 sq = &nic->qs->sq[cqe_tx->sq_idx];
705 hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, cqe_tx->sqe_ptr);
714 dmap = (bus_dmamap_t)sq->snd_buff[cqe_tx->sqe_ptr].dmap;
715 bus_dmamap_unload(sq->snd_buff_dmat, dmap);
717 mbuf = (struct mbuf *)sq->snd_buff[cqe_tx->sqe_ptr].mbuf;
720 sq->snd_buff[cqe_tx->sqe_ptr].mbuf = NULL;
721 nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
739 struct snd_queue *sq = &qs->sq[cq_idx];
812 taskqueue_enqueue(sq->snd_taskq, &sq->snd_task);
867 nicvf_sq_free_used_descs(nic, &qs->sq[qidx], qidx);
868 nicvf_sq_enable(nic, &qs->sq[qidx], qidx);
983 nicvf_xmit_locked(struct snd_queue *sq)
990 NICVF_TX_LOCK_ASSERT(sq);
992 nic = sq->nic;
996 while ((next = drbr_peek(ifp, sq->br)) != NULL) {
1000 err = nicvf_tx_mbuf_locked(sq, &next);
1003 drbr_advance(ifp, sq->br);
1005 drbr_putback(ifp, sq->br, next);
1009 drbr_advance(ifp, sq->br);
1017 struct snd_queue *sq = (struct snd_queue *)arg;
1022 nic = sq->nic;
1033 NICVF_TX_LOCK(sq);
1034 err = nicvf_xmit_locked(sq);
1035 NICVF_TX_UNLOCK(sq);
1038 taskqueue_enqueue(sq->snd_taskq, &sq->snd_task);
1043 nicvf_init_snd_queue(struct nicvf *nic, struct snd_queue *sq, int q_len,
1050 snprintf(sq->mtx_name, sizeof(sq->mtx_name), "%s: SQ(%d) lock",
1052 mtx_init(&sq->mtx, sq->mtx_name, NULL, MTX_DEF);
1054 NICVF_TX_LOCK(sq);
1056 sq->br = buf_ring_alloc(q_len / MIN_SQ_DESC_PER_PKT_XMIT, M_DEVBUF,
1057 M_NOWAIT, &sq->mtx);
1058 if (sq->br == NULL) {
1066 err = nicvf_alloc_q_desc_mem(nic, &sq->dmem, q_len, SND_QUEUE_DESC_SIZE,
1074 sq->desc = sq->dmem.base;
1075 sq->head = sq->tail = 0;
1076 atomic_store_rel_int(&sq->free_cnt, q_len - 1);
1077 sq->thresh = SND_QUEUE_THRESH;
1078 sq->idx = qidx;
1079 sq->nic = nic;
1098 &sq->snd_buff_dmat); /* dmat */
1107 sq->snd_buff = malloc(sizeof(*sq->snd_buff) * q_len, M_NICVF,
1109 if (sq->snd_buff == NULL) {
1118 err = bus_dmamap_create(sq->snd_buff_dmat, 0,
1119 &sq->snd_buff[i].dmap);
1126 NICVF_TX_UNLOCK(sq);
1129 TASK_INIT(&sq->snd_task, 0, nicvf_snd_task, sq);
1130 sq->snd_taskq = taskqueue_create_fast("nicvf_snd_taskq", M_WAITOK,
1131 taskqueue_thread_enqueue, &sq->snd_taskq);
1132 taskqueue_start_threads(&sq->snd_taskq, 1, PI_NET, "%s: snd_taskq(%d)",
1137 NICVF_TX_UNLOCK(sq);
1142 nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq)
1148 if (sq == NULL)
1151 if (sq->snd_taskq != NULL) {
1153 while (taskqueue_cancel(sq->snd_taskq, &sq->snd_task, NULL) != 0)
1154 taskqueue_drain(sq->snd_taskq, &sq->snd_task);
1156 taskqueue_free(sq->snd_taskq);
1157 sq->snd_taskq = NULL;
1160 NICVF_TX_LOCK(sq);
1161 if (sq->snd_buff_dmat != NULL) {
1162 if (sq->snd_buff != NULL) {
1164 m_freem(sq->snd_buff[i].mbuf);
1165 sq->snd_buff[i].mbuf = NULL;
1167 bus_dmamap_unload(sq->snd_buff_dmat,
1168 sq->snd_buff[i].dmap);
1169 err = bus_dmamap_destroy(sq->snd_buff_dmat,
1170 sq->snd_buff[i].dmap);
1182 free(sq->snd_buff, M_NICVF);
1184 err = bus_dma_tag_destroy(sq->snd_buff_dmat);
1190 if (sq->br != NULL)
1191 drbr_free(sq->br, M_DEVBUF);
1193 if (sq->dmem.base != NULL)
1194 nicvf_free_q_desc_mem(nic, &sq->dmem);
1196 NICVF_TX_UNLOCK(sq);
1198 mtx_destroy(&sq->mtx);
1199 memset(sq->mtx_name, 0, sizeof(sq->mtx_name));
1411 struct snd_queue *sq;
1414 sq = &qs->sq[qidx];
1415 sq->enable = enable;
1417 if (!sq->enable) {
1425 sq->cq_qs = qs->vnic_id;
1426 sq->cq_idx = qidx;
1429 mbx.sq.msg = NIC_MBOX_MSG_SQ_CFG;
1430 mbx.sq.qs_num = qs->vnic_id;
1431 mbx.sq.sq_num = qidx;
1432 mbx.sq.sqs_mode = nic->sqs_mode;
1433 mbx.sq.cfg = (sq->cq_qs << 3) | sq->cq_idx;
1438 (uint64_t)(sq->dmem.phys_base));
1449 nicvf_queue_reg_write(nic, NIC_QSET_SQ_0_7_THRESH, qidx, sq->thresh);
1550 nicvf_free_snd_queue(nic, &qs->sq[qidx]);
1568 if (nicvf_init_snd_queue(nic, &qs->sq[qidx], qs->sq_len, qidx))
1661 nicvf_get_sq_desc(struct snd_queue *sq, int desc_cnt)
1665 qentry = sq->tail;
1666 atomic_subtract_int(&sq->free_cnt, desc_cnt);
1667 sq->tail += desc_cnt;
1668 sq->tail &= (sq->dmem.q_len - 1);
1675 nicvf_put_sq_desc(struct snd_queue *sq, int desc_cnt)
1678 atomic_add_int(&sq->free_cnt, desc_cnt);
1679 sq->head += desc_cnt;
1680 sq->head &= (sq->dmem.q_len - 1);
1684 nicvf_get_nxt_sqentry(struct snd_queue *sq, int qentry)
1687 qentry &= (sq->dmem.q_len - 1);
1692 nicvf_sq_enable(struct nicvf *nic, struct snd_queue *sq, int qidx)
1714 nicvf_sq_free_used_descs(struct nicvf *nic, struct snd_queue *sq, int qidx)
1720 NICVF_TX_LOCK(sq);
1722 while (sq->head != head) {
1723 hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, sq->head);
1725 nicvf_put_sq_desc(sq, 1);
1728 snd_buff = &sq->snd_buff[sq->head];
1730 bus_dmamap_unload(sq->snd_buff_dmat, snd_buff->dmap);
1732 sq->snd_buff[sq->head].mbuf = NULL;
1734 nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
1736 NICVF_TX_UNLOCK(sq);
1744 nicvf_sq_add_hdr_subdesc(struct snd_queue *sq, int qentry,
1762 nic = sq->nic;
1764 hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, qentry);
1765 sq->snd_buff[qentry].mbuf = mbuf;
1790 sq->snd_buff[qentry].mbuf = NULL;
1804 sq->snd_buff[qentry].mbuf = mbuf;
1828 sq->snd_buff[qentry].mbuf = mbuf;
1840 sq->snd_buff[qentry].mbuf = mbuf;
1852 sq->snd_buff[qentry].mbuf = mbuf;
1883 static inline void nicvf_sq_add_gather_subdesc(struct snd_queue *sq, int qentry,
1888 qentry &= (sq->dmem.q_len - 1);
1889 gather = (struct sq_gather_subdesc *)GET_SQ_DESC(sq, qentry);
1900 nicvf_tx_mbuf_locked(struct snd_queue *sq, struct mbuf **mbufp)
1909 NICVF_TX_LOCK_ASSERT(sq);
1911 if (sq->free_cnt == 0)
1914 snd_buff = &sq->snd_buff[sq->tail];
1916 err = bus_dmamap_load_mbuf_sg(sq->snd_buff_dmat, snd_buff->dmap,
1927 if (subdesc_cnt > sq->free_cnt) {
1929 bus_dmamap_unload(sq->snd_buff_dmat, snd_buff->dmap);
1933 qentry = nicvf_get_sq_desc(sq, subdesc_cnt);
1936 err = nicvf_sq_add_hdr_subdesc(sq, qentry, subdesc_cnt - 1, *mbufp,
1939 nicvf_put_sq_desc(sq, subdesc_cnt);
1940 bus_dmamap_unload(sq->snd_buff_dmat, snd_buff->dmap);
1950 qentry = nicvf_get_nxt_sqentry(sq, qentry);
1951 nicvf_sq_add_gather_subdesc(sq, qentry, segs[seg].ds_len,
1956 bus_dmamap_sync(sq->dmem.dmat, sq->dmem.dmap, BUS_DMASYNC_PREWRITE);
1958 dprintf(sq->nic->dev, "%s: sq->idx: %d, subdesc_cnt: %d\n",
1959 __func__, sq->idx, subdesc_cnt);
1961 nicvf_queue_reg_write(sq->nic, NIC_QSET_SQ_0_7_DOOR,
1962 sq->idx, subdesc_cnt);
2215 struct snd_queue *sq;
2221 sq = &nic->qs->sq[sq_idx];
2222 sq->stats.bytes = GET_SQ_STATS(RQ_SQ_STATS_OCTS);
2223 sq->stats.pkts = GET_SQ_STATS(RQ_SQ_STATS_PKTS);