net/hns3: move queue stats to xstats
[dpdk.git] / drivers / net / ionic / ionic_dev.c
index c3016b2..aba1713 100644 (file)
@@ -275,6 +275,20 @@ ionic_dev_cmd_port_loopback(struct ionic_dev *idev, uint8_t loopback_mode)
 
 /* LIF commands */
 
+void
+ionic_dev_cmd_queue_identify(struct ionic_dev *idev,
+               uint16_t lif_type, uint8_t qtype, uint8_t qver)
+{
+       union ionic_dev_cmd cmd = {
+               .q_identify.opcode = IONIC_CMD_Q_IDENTIFY,
+               .q_identify.lif_type = rte_cpu_to_le_16(lif_type),
+               .q_identify.type = qtype,
+               .q_identify.ver = qver,
+       };
+
+       ionic_dev_cmd_go(idev, &cmd);
+}
+
 void
 ionic_dev_cmd_lif_identify(struct ionic_dev *idev, uint8_t type, uint8_t ver)
 {
@@ -331,6 +345,7 @@ ionic_dev_cmd_adminq_init(struct ionic_dev *idev, struct ionic_qcq *qcq)
        union ionic_dev_cmd cmd = {
                .q_init.opcode = IONIC_CMD_Q_INIT,
                .q_init.type = q->type,
+               .q_init.ver = qcq->lif->qtype_info[q->type].version,
                .q_init.index = rte_cpu_to_le_32(q->index),
                .q_init.flags = rte_cpu_to_le_16(IONIC_QINIT_F_ENA),
                .q_init.intr_index = rte_cpu_to_le_16(IONIC_INTR_NONE),
@@ -446,12 +461,6 @@ ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
        q->sg_base_pa = base_pa;
 }
 
-void
-ionic_q_flush(struct ionic_queue *q)
-{
-       writeq(IONIC_DBELL_QID(q->hw_index) | q->head_idx, q->db);
-}
-
 void
 ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
             void *cb_arg)
@@ -467,25 +476,6 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
                ionic_q_flush(q);
 }
 
-uint32_t
-ionic_q_space_avail(struct ionic_queue *q)
-{
-       uint32_t avail = q->tail_idx;
-
-       if (q->head_idx >= avail)
-               avail += q->num_descs - q->head_idx - 1;
-       else
-               avail -= q->head_idx + 1;
-
-       return avail;
-}
-
-bool
-ionic_q_has_space(struct ionic_queue *q, uint32_t want)
-{
-       return ionic_q_space_avail(q) >= want;
-}
-
 void
 ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
                uint32_t stop_index, void *service_cb_arg)
@@ -554,7 +544,7 @@ ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 
        rte_spinlock_lock(&lif->adminq_lock);
 
-       if (!ionic_q_has_space(adminq, 1)) {
+       if (ionic_q_space_avail(adminq) < 1) {
                err = -ENOSPC;
                goto err_out;
        }