}
if (rxqs_n == priv->rxqs_n)
return 0;
- if (!rte_is_power_of_2(rxqs_n)) {
+ if (!rte_is_power_of_2(rxqs_n) && !priv->isolated) {
unsigned n_active;
n_active = rte_align32pow2(rxqs_n + 1) >> 1;
{
unsigned int i;
+ assert(!priv->isolated);
assert(mac_index < elemof(priv->mac));
if (!BITFIELD_ISSET(priv->mac_configured, mac_index))
return;
rxq->if_cq,
¶ms));
}
- if (rxq->qp != NULL) {
+ if (rxq->qp != NULL && !rxq->priv->isolated) {
rxq_promiscuous_disable(rxq);
rxq_allmulticast_disable(rxq);
rxq_mac_addrs_del(rxq);
- claim_zero(ibv_destroy_qp(rxq->qp));
}
+ if (rxq->qp != NULL)
+ claim_zero(ibv_destroy_qp(rxq->qp));
if (rxq->cq != NULL)
claim_zero(ibv_destroy_cq(rxq->cq));
if (rxq->channel != NULL)
return 0;
}
/* Remove attached flows if RSS is disabled (no parent queue). */
- if (!priv->rss) {
+ if (!priv->rss && !priv->isolated) {
rxq_allmulticast_disable(&tmpl);
rxq_promiscuous_disable(&tmpl);
rxq_mac_addrs_del(&tmpl);
return err;
};
/* Reconfigure flows. Do not care for errors. */
- if (!priv->rss) {
+ if (!priv->rss && !priv->isolated) {
rxq_mac_addrs_add(&tmpl);
if (priv->promisc)
rxq_promiscuous_enable(&tmpl);
(void *)dev, strerror(ret));
goto error;
}
- if ((parent) || (!priv->rss)) {
+ if (!priv->isolated && (parent || !priv->rss)) {
/* Configure MAC and broadcast addresses. */
ret = rxq_mac_addrs_add(&tmpl);
if (ret) {
}
DEBUG("%p: attaching configured flows to all RX queues", (void *)dev);
priv->started = 1;
- if (priv->rss) {
+ if (priv->isolated) {
+ rxq = NULL;
+ r = 1;
+ } else if (priv->rss) {
rxq = &priv->rxq_parent;
r = 1;
} else {
}
DEBUG("%p: detaching flows from all RX queues", (void *)dev);
priv->started = 0;
- if (priv->rss) {
+ if (priv->isolated) {
+ rxq = NULL;
+ r = 1;
+ } else if (priv->rss) {
rxq = &priv->rxq_parent;
r = 1;
} else {
if (mlx4_is_secondary())
return;
priv_lock(priv);
+ if (priv->isolated)
+ goto end;
DEBUG("%p: removing MAC address from index %" PRIu32,
(void *)dev, index);
/* Last array entry is reserved for broadcast. */
return -ENOTSUP;
(void)vmdq;
priv_lock(priv);
+ if (priv->isolated) {
+ DEBUG("%p: cannot add MAC address, "
+ "device is in isolated mode", (void *)dev);
+ re = EPERM;
+ goto end;
+ }
DEBUG("%p: adding MAC address at index %" PRIu32,
(void *)dev, index);
/* Last array entry is reserved for broadcast. */
if (mlx4_is_secondary())
return;
priv_lock(priv);
+ if (priv->isolated) {
+ DEBUG("%p: cannot enable promiscuous, "
+ "device is in isolated mode", (void *)dev);
+ priv_unlock(priv);
+ return;
+ }
if (priv->promisc) {
priv_unlock(priv);
return;
if (mlx4_is_secondary())
return;
priv_lock(priv);
- if (!priv->promisc) {
+ if (!priv->promisc || priv->isolated) {
priv_unlock(priv);
return;
}
if (mlx4_is_secondary())
return;
priv_lock(priv);
+ if (priv->isolated) {
+ DEBUG("%p: cannot enable allmulticast, "
+ "device is in isolated mode", (void *)dev);
+ priv_unlock(priv);
+ return;
+ }
if (priv->allmulti) {
priv_unlock(priv);
return;
if (mlx4_is_secondary())
return;
priv_lock(priv);
- if (!priv->allmulti) {
+ if (!priv->allmulti || priv->isolated) {
priv_unlock(priv);
return;
}
}
/* Reenable non-RSS queue attributes. No need to check
* for errors at this stage. */
- if (!priv->rss) {
+ if (!priv->rss && !priv->isolated) {
rxq_mac_addrs_add(rxq);
if (priv->promisc)
rxq_promiscuous_enable(rxq);
if (mlx4_is_secondary())
return -E_RTE_SECONDARY;
priv_lock(priv);
+ if (priv->isolated) {
+ DEBUG("%p: cannot set vlan filter, "
+ "device is in isolated mode", (void *)dev);
+ priv_unlock(priv);
+ return -EINVAL;
+ }
ret = vlan_filter_set(dev, vlan_id, on);
priv_unlock(priv);
assert(ret >= 0);
.destroy = mlx4_flow_destroy,
.flush = mlx4_flow_flush,
.query = NULL,
+ .isolate = mlx4_flow_isolate,
};
/**
return flow;
}
+/**
+ * @see rte_flow_isolate()
+ *
+ * Must be done before calling dev_configure().
+ *
+ * @param dev
+ * Pointer to the ethernet device structure.
+ * @param enable
+ * Nonzero to enter isolated mode, attempt to leave it otherwise.
+ * @param[out] error
+ * Perform verbose error reporting if not NULL. PMDs initialize this
+ * structure in case of error only.
+ *
+ * @return
+ * 0 on success, a negative value on error.
+ */
+int
+mlx4_flow_isolate(struct rte_eth_dev *dev,
+ int enable,
+ struct rte_flow_error *error)
+{
+ struct priv *priv = dev->data->dev_private;
+
+ priv_lock(priv);
+ if (priv->rxqs) {
+ rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "isolated mode must be set"
+ " before configuring the device");
+ priv_unlock(priv);
+ return -rte_errno;
+ }
+ priv->isolated = !!enable;
+ priv_unlock(priv);
+ return 0;
+}
+
/**
* Destroy a flow.
*