-
- if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
- PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
- port_id, dev->data->dev_conf.fdir_conf.mode);
- return (-ENOSYS);
- }
-
- if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
- || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
- && (fdir_filter->port_src || fdir_filter->port_dst)) {
- PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
- "None l4type, source & destinations ports " \
- "should be null!\n");
- return (-EINVAL);
- }
-
- /* For now IPv6 is not supported with perfect filter */
- if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
- return (-ENOTSUP);
-
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
- return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
- soft_id);
-}
-
-int
-rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
-
- dev = &rte_eth_devices[port_id];
- if (! (dev->data->dev_conf.fdir_conf.mode)) {
- PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
- return (-ENOSYS);
- }
-
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
- return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
-}
-
-int
-rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
- memset(fc_conf, 0, sizeof(*fc_conf));
- return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
-}
-
-int
-rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
-
- if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
- PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
- return (-EINVAL);
- }
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
- return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
-}
-
-int
-rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_conf)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
-
- if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
- PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
- return (-EINVAL);
- }
-
- dev = &rte_eth_devices[port_id];
- /* High water, low water validation are device specific */
- if (*dev->dev_ops->priority_flow_ctrl_set)
- return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf);
- return (-ENOTSUP);
-}
-
-static inline int
-rte_eth_check_reta_mask(struct rte_eth_rss_reta_entry64 *reta_conf,
- uint16_t reta_size)
-{
- uint16_t i, num;
-
- if (!reta_conf)
- return -EINVAL;
-
- if (reta_size != RTE_ALIGN(reta_size, RTE_RETA_GROUP_SIZE)) {
- PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
- RTE_RETA_GROUP_SIZE);
- return -EINVAL;
- }
-
- num = reta_size / RTE_RETA_GROUP_SIZE;
- for (i = 0; i < num; i++) {
- if (reta_conf[i].mask)
- return 0;
- }
-
- return -EINVAL;
-}
-
-static inline int
-rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
- uint16_t reta_size,
- uint8_t max_rxq)
-{
- uint16_t i, idx, shift;
-
- if (!reta_conf)
- return -EINVAL;
-
- if (max_rxq == 0) {
- PMD_DEBUG_TRACE("No receive queue is available\n");
- return -EINVAL;
- }
-
- for (i = 0; i < reta_size; i++) {
- idx = i / RTE_RETA_GROUP_SIZE;
- shift = i % RTE_RETA_GROUP_SIZE;
- if ((reta_conf[idx].mask & (1ULL << shift)) &&
- (reta_conf[idx].reta[shift] >= max_rxq)) {
- PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
- "the maximum rxq index: %u\n", idx, shift,
- reta_conf[idx].reta[shift], max_rxq);
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-int
-rte_eth_dev_rss_reta_update(uint8_t port_id,
- struct rte_eth_rss_reta_entry64 *reta_conf,
- uint16_t reta_size)
-{
- struct rte_eth_dev *dev;
- int ret;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- /* Check mask bits */
- ret = rte_eth_check_reta_mask(reta_conf, reta_size);
- if (ret < 0)
- return ret;
-
- dev = &rte_eth_devices[port_id];
-
- /* Check entry value */
- ret = rte_eth_check_reta_entry(reta_conf, reta_size,
- dev->data->nb_rx_queues);
- if (ret < 0)
- return ret;
-
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
- return (*dev->dev_ops->reta_update)(dev, reta_conf, reta_size);
-}
-
-int
-rte_eth_dev_rss_reta_query(uint8_t port_id,
- struct rte_eth_rss_reta_entry64 *reta_conf,
- uint16_t reta_size)
-{
- struct rte_eth_dev *dev;
- int ret;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return -ENODEV;
- }
-
- /* Check mask bits */
- ret = rte_eth_check_reta_mask(reta_conf, reta_size);
- if (ret < 0)
- return ret;
-
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
- return (*dev->dev_ops->reta_query)(dev, reta_conf, reta_size);
-}
-
-int
-rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
-{
- struct rte_eth_dev *dev;
- uint16_t rss_hash_protos;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
- rss_hash_protos = rss_conf->rss_hf;
- if ((rss_hash_protos != 0) &&
- ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
- PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
- rss_hash_protos);
- return (-EINVAL);
- }
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
- return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
-}
-
-int
-rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
- struct rte_eth_rss_conf *rss_conf)
-{
- struct rte_eth_dev *dev;
-
- if (port_id >= nb_ports) {
- PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return (-ENODEV);
- }
- dev = &rte_eth_devices[port_id];
- FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
- return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
-}