LIST_ENTRY(ionic_adapter) pci_adapters;
};
-int ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout);
+/** ionic_admin_ctx - Admin command context.
+ * @pending_work: Flag that indicates a completion.
+ * @cmd: Admin command (64B) to be copied to the queue.
+ * @comp: Admin completion (16B) copied from the queue.
+ */
+struct ionic_admin_ctx {
+ bool pending_work;
+ union ionic_adminq_cmd cmd;
+ union ionic_adminq_comp comp;
+};
+
int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
+
int ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait);
int ionic_setup(struct ionic_adapter *adapter);
if (ring_doorbell)
ionic_q_flush(q);
}
-
-void
-ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
- uint32_t stop_index, void *service_cb_arg)
-{
- struct ionic_desc_info *desc_info;
- uint32_t curr_q_tail_idx;
-
- do {
- desc_info = &q->info[q->tail_idx];
-
- if (desc_info->cb)
- desc_info->cb(q, q->tail_idx, cq_desc_index,
- desc_info->cb_arg, service_cb_arg);
-
- desc_info->cb = NULL;
- desc_info->cb_arg = NULL;
-
- curr_q_tail_idx = q->tail_idx;
- q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
-
- } while (curr_q_tail_idx != stop_index);
-}
-
-static void
-ionic_adminq_cb(struct ionic_queue *q,
- uint32_t q_desc_index, uint32_t cq_desc_index,
- void *cb_arg, void *service_cb_arg __rte_unused)
-{
- struct ionic_admin_ctx *ctx = cb_arg;
- struct ionic_admin_comp *cq_desc_base = q->bound_cq->base;
- struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
- uint16_t comp_index;
-
- if (!ctx)
- return;
-
- comp_index = rte_le_to_cpu_16(cq_desc->comp_index);
- if (unlikely(comp_index != q_desc_index)) {
- IONIC_WARN_ON(comp_index != q_desc_index);
- return;
- }
-
- memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
-
- ctx->pending_work = false; /* done */
-}
-
-/** ionic_adminq_post - Post an admin command.
- * @lif: Handle to lif.
- * @cmd_ctx: Api admin command context.
- *
- * Post the command to an admin queue in the ethernet driver. If this command
- * succeeds, then the command has been posted, but that does not indicate a
- * completion. If this command returns success, then the completion callback
- * will eventually be called.
- *
- * Return: zero or negative error status.
- */
-int
-ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
-{
- struct ionic_queue *adminq = &lif->adminqcq->q;
- struct ionic_admin_cmd *q_desc_base = adminq->base;
- struct ionic_admin_cmd *q_desc;
- int err = 0;
-
- rte_spinlock_lock(&lif->adminq_lock);
-
- if (ionic_q_space_avail(adminq) < 1) {
- err = -ENOSPC;
- goto err_out;
- }
-
- q_desc = &q_desc_base[adminq->head_idx];
-
- memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
-
- ionic_q_post(adminq, true, ionic_adminq_cb, ctx);
-
-err_out:
- rte_spinlock_unlock(&lif->adminq_lock);
-
- return err;
-}
rte_iova_t base_pa;
};
-/** ionic_admin_ctx - Admin command context.
- * @pending_work: Flag that indicates a completion.
- * @cmd: Admin command (64B) to be copied to the queue.
- * @comp: Admin completion (16B) copied from the queue.
- */
-struct ionic_admin_ctx {
- bool pending_work;
- union ionic_adminq_cmd cmd;
- union ionic_adminq_comp comp;
-};
-
struct ionic_lif;
struct ionic_adapter;
struct ionic_qcq;
void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
void *cb_arg);
-void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
- uint32_t stop_index, void *service_cb_arg);
static inline uint32_t
ionic_q_space_avail(struct ionic_queue *q)
rte_write64(rte_cpu_to_le_64(val), q->db);
}
-int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
-
#endif /* _IONIC_DEV_H_ */
nqcq->flags &= ~IONIC_QCQ_F_INITED;
}
-bool
-ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
- void *cb_arg __rte_unused)
-{
- struct ionic_admin_comp *cq_desc_base = cq->base;
- struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
- struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
-
- if (!color_match(cq_desc->color, cq->done_color))
- return false;
-
- ionic_q_service(&qcq->q, cq_desc_index, cq_desc->comp_index, NULL);
-
- return true;
-}
-
/* This acts like ionic_napi */
int
ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
void ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr);
-bool ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
- void *cb_arg);
int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
void *cb_arg);
}
}
-int
+static int
ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
{
const char *name;
return 0;
}
+static bool
+ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
+ void *cb_arg __rte_unused)
+{
+ struct ionic_admin_comp *cq_desc_base = cq->base;
+ struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
+ struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
+ struct ionic_queue *q = &qcq->q;
+ struct ionic_admin_ctx *ctx;
+ struct ionic_desc_info *desc_info;
+ uint16_t curr_q_tail_idx;
+ uint16_t stop_index;
+
+ if (!color_match(cq_desc->color, cq->done_color))
+ return false;
+
+ stop_index = rte_le_to_cpu_16(cq_desc->comp_index);
+
+ do {
+ desc_info = &q->info[q->tail_idx];
+
+ ctx = desc_info->cb_arg;
+ if (ctx) {
+ memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
+
+ ctx->pending_work = false; /* done */
+ }
+
+ curr_q_tail_idx = q->tail_idx;
+ q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+ } while (curr_q_tail_idx != stop_index);
+
+ return true;
+}
+
+/** ionic_adminq_post - Post an admin command.
+ * @lif: Handle to lif.
+ * @cmd_ctx: Api admin command context.
+ *
+ * Post the command to an admin queue in the ethernet driver. If this command
+ * succeeds, then the command has been posted, but that does not indicate a
+ * completion. If this command returns success, then the completion callback
+ * will eventually be called.
+ *
+ * Return: zero or negative error status.
+ */
+static int
+ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
+{
+ struct ionic_queue *q = &lif->adminqcq->q;
+ struct ionic_admin_cmd *q_desc_base = q->base;
+ struct ionic_admin_cmd *q_desc;
+ int err = 0;
+
+ rte_spinlock_lock(&lif->adminq_lock);
+
+ if (ionic_q_space_avail(q) < 1) {
+ err = -ENOSPC;
+ goto err_out;
+ }
+
+ q_desc = &q_desc_base[q->head_idx];
+
+ memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
+
+ ionic_q_post(q, true, NULL, ctx);
+
+err_out:
+ rte_spinlock_unlock(&lif->adminq_lock);
+
+ return err;
+}
+
static int
-ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
+ionic_adminq_wait_for_completion(struct ionic_lif *lif,
struct ionic_admin_ctx *ctx, unsigned long max_wait)
{
unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
while (ctx->pending_work && elapsed_usec < max_wait_usec) {
/*
- * Locking here as adminq is served inline (this could be called
- * from multiple places)
+ * Locking here as adminq is served inline and could be
+ * called from multiple places
*/
rte_spinlock_lock(&lif->adminq_service_lock);
- ionic_qcq_service(qcq, budget, ionic_adminq_service, NULL);
+ ionic_qcq_service(lif->adminqcq, budget,
+ ionic_adminq_service, NULL);
rte_spinlock_unlock(&lif->adminq_service_lock);
int
ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
{
- struct ionic_qcq *qcq = lif->adminqcq;
bool done;
int err;
return err;
}
- done = ionic_wait_ctx_for_completion(lif, qcq, ctx,
+ done = ionic_adminq_wait_for_completion(lif, ctx,
IONIC_DEVCMD_TIMEOUT);
return ionic_adminq_check_err(ctx, !done /* timed out */);
#include <rte_malloc.h>
+#include "ionic.h"
#include "ionic_lif.h"
#include "ionic_rx_filter.h"