/** * dpaa2_io_service_enqueue_qd() - Enqueue a frame to a QD. * @d: the given DPIO service. * @qdid: the given queuing destination id. * @prio: the given queuing priority. * @qdbin: the given queuing destination bin. * @fd: the frame descriptor which is enqueued. * * Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready, * or -ENODEV if there is no dpio service. */ int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio, u16 qdbin, const struct dpaa2_fd *fd) { struct qbman_eq_desc ed; d = service_select(d); if (!d) return -ENODEV; qbman_eq_desc_clear(&ed); qbman_eq_desc_set_no_orp(&ed, 0); qbman_eq_desc_set_qd(&ed, qdid, qdbin, prio); return qbman_swp_enqueue(d->swp, &ed, fd); }
/** * dpaa2_io_service_enqueue_fq() - Enqueue a frame to a frame queue. * @d: the given DPIO service. * @fqid: the given frame queue id. * @fd: the frame descriptor which is enqueued. * * Return 0 for successful enqueue, -EBUSY if the enqueue ring is not ready, * or -ENODEV if there is no dpio service. */ int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid, const struct dpaa2_fd *fd) { struct qbman_eq_desc ed; d = service_select(d); if (!d) return -ENODEV; qbman_eq_desc_clear(&ed); qbman_eq_desc_set_no_orp(&ed, 0); qbman_eq_desc_set_fq(&ed, fqid); return qbman_swp_enqueue(d->swp, &ed, fd); }
static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len) { struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; struct dpaa_fd fd; u64 buffer_start; int data_offset, err; u32 timeo = (CONFIG_SYS_HZ * 10) / 1000; u32 time_start; struct qbman_swp *swp = dflt_dpio->sw_portal; struct qbman_eq_desc ed; struct qbman_release_desc releasedesc; /* Setup the FD fields */ memset(&fd, 0, sizeof(fd)); data_offset = priv->tx_data_offset; do { err = qbman_swp_acquire(dflt_dpio->sw_portal, dflt_dpbp->dpbp_attr.bpid, &buffer_start, 1); } while (err == -EBUSY); if (err < 0) { printf("qbman_swp_acquire() failed\n"); return -ENOMEM; } debug("TX data: malloc buffer start=0x%p\n", (u64 *)buffer_start); memcpy(((uint8_t *)(buffer_start) + data_offset), buf, len); flush_dcache_range(buffer_start, buffer_start + LDPAA_ETH_RX_BUFFER_SIZE); ldpaa_fd_set_addr(&fd, (u64)buffer_start); ldpaa_fd_set_offset(&fd, (uint16_t)(data_offset)); ldpaa_fd_set_bpid(&fd, dflt_dpbp->dpbp_attr.bpid); ldpaa_fd_set_len(&fd, len); fd.simple.ctrl = LDPAA_FD_CTRL_ASAL | LDPAA_FD_CTRL_PTA | LDPAA_FD_CTRL_PTV1; qbman_eq_desc_clear(&ed); qbman_eq_desc_set_no_orp(&ed, 0); qbman_eq_desc_set_qd(&ed, priv->tx_qdid, priv->tx_flow_id, 0); time_start = get_timer(0); while (get_timer(time_start) < timeo) { err = qbman_swp_enqueue(swp, &ed, (const struct qbman_fd *)(&fd)); if (err != -EBUSY) break; } if (err < 0) { printf("error enqueueing Tx frame\n"); goto error; } return err; error: qbman_release_desc_clear(&releasedesc); qbman_release_desc_set_bpid(&releasedesc, dflt_dpbp->dpbp_attr.bpid); time_start = get_timer(0); do { /* Release buffer into the QBMAN */ err = qbman_swp_release(swp, &releasedesc, &buffer_start, 1); } while (get_timer(time_start) < timeo && err == -EBUSY); if (err == -EBUSY) printf("TX data: QBMAN buffer release fails\n"); return err; }