From: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
This patch addsbnxt query callback to rte_flow_ops in non TruFlow mode.
At this point only the RSS hash function type is displayed.
Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_flow.c | 61 ++++++++++++++++++++++++++++++++++++
drivers/net/bnxt/bnxt_vnic.c | 11 +++++++
drivers/net/bnxt/bnxt_vnic.h | 2 ++
3 files changed, 74 insertions(+)
@@ -1917,6 +1917,66 @@ void bnxt_flow_cnt_alarm_cb(void *arg)
(void *)bp);
}
+/* Query an requested flow rule. */
+static int
+bnxt_flow_query_all(struct rte_flow *flow,
+ const struct rte_flow_action *actions, void *data,
+ struct rte_flow_error *error)
+{
+ struct rte_flow_action_rss *rss_conf;
+ struct bnxt_vnic_info *vnic;
+
+ vnic = flow->vnic;
+ if (vnic == NULL)
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_HANDLE, flow,
+ "Invalid flow: failed to query flow.");
+
+ for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+ switch (actions->type) {
+ case RTE_FLOW_ACTION_TYPE_VOID:
+ break;
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+ break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+ /* Full details of rte_flow_action_rss not available yet TBD*/
+ rss_conf = (struct rte_flow_action_rss *)data;
+
+ /* toeplitz is default */
+ if (vnic->ring_select_mode ==
+ HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ)
+ rss_conf->func = vnic->hash_f_local;
+ else
+ rss_conf->func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
+
+ break;
+ default:
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION, actions,
+ "action is not supported");
+ }
+ }
+
+ return 0;
+}
+
+static int
+bnxt_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
+ const struct rte_flow_action *actions, void *data,
+ struct rte_flow_error *error)
+{
+ struct bnxt *bp = dev->data->dev_private;
+ int ret = 0;
+
+ if (bp == NULL)
+ return -ENODEV;
+
+ bnxt_acquire_flow_lock(bp);
+ ret = bnxt_flow_query_all(flow, actions, data, error);
+ bnxt_release_flow_lock(bp);
+
+ return ret;
+}
static struct rte_flow *
bnxt_flow_create(struct rte_eth_dev *dev,
@@ -2374,4 +2434,5 @@ const struct rte_flow_ops bnxt_flow_ops = {
.create = bnxt_flow_create,
.destroy = bnxt_flow_destroy,
.flush = bnxt_flow_flush,
+ .query = bnxt_flow_query,
};
@@ -1335,6 +1335,9 @@ int bnxt_rte_flow_to_hwrm_ring_select_mode(enum rte_eth_hash_function hash_f,
}
vnic->ring_select_mode = _bnxt_rte_to_hwrm_ring_select_mode(hash_f);
+ vnic->hash_f_local = hash_f;
+ /* shadow copy types as !hash_f is always true with default func */
+ vnic->rss_types_local = types;
return 0;
}
@@ -1359,6 +1362,8 @@ int bnxt_rte_eth_to_hwrm_ring_select_mode(struct bnxt *bp, uint64_t types,
*/
vnic->ring_select_mode =
HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ;
+ vnic->hash_f_local =
+ HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ;
return 0;
}
@@ -1367,6 +1372,12 @@ void bnxt_hwrm_rss_to_rte_hash_conf(struct bnxt_vnic_info *vnic,
{
uint32_t hash_types;
+ /* check for local shadow rte types */
+ if (vnic->rss_types_local != 0) {
+ *rss_conf = vnic->rss_types_local;
+ return;
+ }
+
hash_types = vnic->hash_type;
*rss_conf = 0;
if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4)
@@ -79,6 +79,8 @@ struct bnxt_vnic_info {
STAILQ_HEAD(, bnxt_filter_info) filter;
STAILQ_HEAD(, rte_flow) flow_list;
uint8_t ring_select_mode;
+ enum rte_eth_hash_function hash_f_local;
+ uint64_t rss_types_local;
};
struct bnxt_vnic_queue_db {