}
/**
- * Set device MTU.
+ * DPDK callback to change the MTU.
*
* @param priv
- * Pointer to private structure.
+ * Pointer to Ethernet device structure.
* @param mtu
* MTU value to set.
*
* 0 on success, negative errno value otherwise and rte_errno is set.
*/
static int
-priv_set_mtu(struct priv *priv, uint16_t mtu)
+mlx4_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
{
+ struct priv *priv = dev->data->dev_private;
uint16_t new_mtu;
int ret = priv_set_sysfs_ulong(priv, "mtu", mtu);
ret = priv_get_mtu(priv, &new_mtu);
if (ret)
return ret;
- if (new_mtu == mtu)
+ if (new_mtu == mtu) {
+ priv->mtu = mtu;
return 0;
+ }
rte_errno = EINVAL;
return -rte_errno;
}
priv_mac_addr_del(struct priv *priv);
/**
- * Ethernet device configuration.
+ * DPDK callback for Ethernet device configuration.
*
* Prepare the driver for a given number of TX and RX queues.
*
* 0 on success, negative errno value otherwise and rte_errno is set.
*/
static int
-dev_configure(struct rte_eth_dev *dev)
+mlx4_dev_configure(struct rte_eth_dev *dev)
{
struct priv *priv = dev->data->dev_private;
unsigned int rxqs_n = dev->data->nb_rx_queues;
return 0;
}
-/**
- * DPDK callback for Ethernet device configuration.
- *
- * @param dev
- * Pointer to Ethernet device structure.
- *
- * @return
- * 0 on success, negative errno value otherwise and rte_errno is set.
- */
-static int
-mlx4_dev_configure(struct rte_eth_dev *dev)
-{
- return dev_configure(dev);
-}
-
static uint16_t mlx4_tx_burst(void *, struct rte_mbuf **, uint16_t);
static uint16_t removed_rx_burst(void *, struct rte_mbuf **, uint16_t);
return 0;
}
-/**
- * DPDK callback to change the MTU.
- *
- * @param dev
- * Pointer to Ethernet device structure.
- * @param in_mtu
- * New MTU.
- *
- * @return
- * 0 on success, negative errno value otherwise and rte_errno is set.
- */
-static int
-mlx4_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
-{
- struct priv *priv = dev->data->dev_private;
- int ret = 0;
-
- /* Set kernel interface MTU first. */
- if (priv_set_mtu(priv, mtu)) {
- ret = rte_errno;
- WARN("cannot set port %u MTU to %u: %s", priv->port, mtu,
- strerror(rte_errno));
- goto out;
- } else
- DEBUG("adapter port %u MTU set to %u", priv->port, mtu);
- priv->mtu = mtu;
-out:
- assert(ret >= 0);
- return -ret;
-}
-
/**
* DPDK callback to get flow control status.
*
}
/**
- * Convert a flow.
- *
- * @param priv
- * Pointer to private structure.
- * @param[in] attr
- * Flow rule attributes.
- * @param[in] items
- * Pattern specification (list terminated by the END pattern item).
- * @param[in] actions
- * Associated actions (list terminated by the END action).
- * @param[out] error
- * Perform verbose error reporting if not NULL.
+ * Create a flow.
*
- * @return
- * A flow on success, NULL otherwise.
+ * @see rte_flow_create()
+ * @see rte_flow_ops
*/
-static struct rte_flow *
-priv_flow_create(struct priv *priv,
+struct rte_flow *
+mlx4_flow_create(struct rte_eth_dev *dev,
const struct rte_flow_attr *attr,
const struct rte_flow_item items[],
const struct rte_flow_action actions[],
struct rte_flow_error *error)
{
+ struct priv *priv = dev->data->dev_private;
struct rte_flow *rte_flow;
struct mlx4_flow_action action;
struct mlx4_flow flow = { .offset = sizeof(struct ibv_flow_attr), };
}
rte_flow = priv_flow_create_action_queue(priv, flow.ibv_attr,
&action, error);
- if (rte_flow)
+ if (rte_flow) {
+ LIST_INSERT_HEAD(&priv->flows, rte_flow, next);
+ DEBUG("Flow created %p", (void *)rte_flow);
return rte_flow;
+ }
exit:
rte_free(flow.ibv_attr);
return NULL;
}
-/**
- * Create a flow.
- *
- * @see rte_flow_create()
- * @see rte_flow_ops
- */
-struct rte_flow *
-mlx4_flow_create(struct rte_eth_dev *dev,
- const struct rte_flow_attr *attr,
- const struct rte_flow_item items[],
- const struct rte_flow_action actions[],
- struct rte_flow_error *error)
-{
- struct priv *priv = dev->data->dev_private;
- struct rte_flow *flow;
-
- flow = priv_flow_create(priv, attr, items, actions, error);
- if (flow) {
- LIST_INSERT_HEAD(&priv->flows, flow, next);
- DEBUG("Flow created %p", (void *)flow);
- }
- return flow;
-}
-
/**
* @see rte_flow_isolate()
*
return 0;
}
-/**
- * Destroy a flow.
- *
- * @param priv
- * Pointer to private structure.
- * @param[in] flow
- * Flow to destroy.
- */
-static void
-priv_flow_destroy(struct priv *priv, struct rte_flow *flow)
-{
- (void)priv;
- LIST_REMOVE(flow, next);
- if (flow->ibv_flow)
- claim_zero(ibv_destroy_flow(flow->ibv_flow));
- rte_free(flow->ibv_attr);
- DEBUG("Flow destroyed %p", (void *)flow);
- rte_free(flow);
-}
-
/**
* Destroy a flow.
*
struct rte_flow *flow,
struct rte_flow_error *error)
{
- struct priv *priv = dev->data->dev_private;
-
+ (void)dev;
(void)error;
- priv_flow_destroy(priv, flow);
+ LIST_REMOVE(flow, next);
+ if (flow->ibv_flow)
+ claim_zero(ibv_destroy_flow(flow->ibv_flow));
+ rte_free(flow->ibv_attr);
+ DEBUG("Flow destroyed %p", (void *)flow);
+ rte_free(flow);
return 0;
}
-/**
- * Destroy all flows.
- *
- * @param priv
- * Pointer to private structure.
- */
-static void
-priv_flow_flush(struct priv *priv)
-{
- while (!LIST_EMPTY(&priv->flows)) {
- struct rte_flow *flow;
-
- flow = LIST_FIRST(&priv->flows);
- priv_flow_destroy(priv, flow);
- }
-}
-
/**
* Destroy all flows.
*
{
struct priv *priv = dev->data->dev_private;
- (void)error;
- priv_flow_flush(priv);
+ while (!LIST_EMPTY(&priv->flows)) {
+ struct rte_flow *flow;
+
+ flow = LIST_FIRST(&priv->flows);
+ mlx4_flow_destroy(dev, flow, error);
+ }
return 0;
}