ethdev: rename port mirroring structure
authorJingjing Wu <jingjing.wu@intel.com>
Wed, 10 Jun 2015 06:24:30 +0000 (14:24 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 7 Jul 2015 15:39:32 +0000 (17:39 +0200)
Rename rte_eth_vmdq_mirror_conf to rte_eth_mirror_conf and move
the maximum rule id check from ethdev level to driver.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
app/test-pmd/cmdline.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/ixgbe/ixgbe_ethdev.h
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h

index 95a8f95..aa37a8c 100644 (file)
@@ -6668,11 +6668,11 @@ cmd_set_mirror_mask_parsed(void *parsed_result,
 {
        int ret,nb_item,i;
        struct cmd_set_mirror_mask_result *res = parsed_result;
-       struct rte_eth_vmdq_mirror_conf mr_conf;
+       struct rte_eth_mirror_conf mr_conf;
 
-       memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
+       memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
 
-       unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
+       unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
 
        mr_conf.dst_pool = res->dstpool_id;
 
@@ -6682,11 +6682,11 @@ cmd_set_mirror_mask_parsed(void *parsed_result,
        } else if(!strcmp(res->what, "vlan-mirror")) {
                mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
                nb_item = parse_item_list(res->value, "core",
-                                       ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
+                                       ETH_MIRROR_MAX_VLANS, vlan_list, 1);
                if (nb_item <= 0)
                        return;
 
-               for(i=0; i < nb_item; i++) {
+               for (i = 0; i < nb_item; i++) {
                        if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
                                printf("Invalid vlan_id: must be < 4096\n");
                                return;
@@ -6698,10 +6698,10 @@ cmd_set_mirror_mask_parsed(void *parsed_result,
        }
 
        if(!strcmp(res->on, "on"))
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 1);
        else
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 0);
        if(ret < 0)
                printf("mirror rule add error: (%s)\n", strerror(-ret));
@@ -6775,9 +6775,9 @@ cmd_set_mirror_link_parsed(void *parsed_result,
 {
        int ret;
        struct cmd_set_mirror_link_result *res = parsed_result;
-       struct rte_eth_vmdq_mirror_conf mr_conf;
+       struct rte_eth_mirror_conf mr_conf;
 
-       memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
+       memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
        if(!strcmp(res->what, "uplink-mirror")) {
                mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
        }else if(!strcmp(res->what, "downlink-mirror"))
@@ -6786,10 +6786,10 @@ cmd_set_mirror_link_parsed(void *parsed_result,
        mr_conf.dst_pool = res->dstpool_id;
 
        if(!strcmp(res->on, "on"))
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 1);
        else
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 0);
 
        /* check the return value and print it if is < 0 */
index f18550c..deb4423 100644 (file)
@@ -209,7 +209,7 @@ static int ixgbe_set_pool_tx(struct rte_eth_dev *dev,uint16_t pool,uint8_t on);
 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
                uint64_t pool_mask,uint8_t vlan_on);
 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
-               struct rte_eth_vmdq_mirror_conf *mirror_conf,
+               struct rte_eth_mirror_conf *mirror_conf,
                uint8_t rule_id, uint8_t on);
 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
                uint8_t rule_id);
@@ -3416,7 +3416,7 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
 
 static int
 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
-                       struct rte_eth_vmdq_mirror_conf *mirror_conf,
+                       struct rte_eth_mirror_conf *mirror_conf,
                        uint8_t rule_id, uint8_t on)
 {
        uint32_t mr_ctl,vlvf;
@@ -3440,7 +3440,10 @@ ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
                IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        if (ixgbe_vmdq_mode_check(hw) < 0)
-               return (-ENOTSUP);
+               return -ENOTSUP;
+
+       if (rule_id >= IXGBE_MAX_MIRROR_RULES)
+               return -EINVAL;
 
        /* Check if vlan mask is valid */
        if ((mirror_conf->rule_type_mask & ETH_VMDQ_VLAN_MIRROR) && (on)) {
@@ -3554,7 +3557,7 @@ ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
                return (-ENOTSUP);
 
        memset(&mr_info->mr_conf[rule_id], 0,
-               sizeof(struct rte_eth_vmdq_mirror_conf));
+               sizeof(struct rte_eth_mirror_conf));
 
        /* clear PFVMCTL register */
        IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
index 19237b8..755b674 100644 (file)
@@ -177,8 +177,10 @@ struct ixgbe_uta_info {
        uint32_t uta_shadow[IXGBE_MAX_UTA];
 };
 
+#define IXGBE_MAX_MIRROR_RULES 4  /* Maximum nb. of mirror rules. */
+
 struct ixgbe_mirror_info {
-       struct rte_eth_vmdq_mirror_conf mr_conf[ETH_VMDQ_NUM_MIRROR_RULE];
+       struct rte_eth_mirror_conf mr_conf[IXGBE_MAX_MIRROR_RULES];
        /**< store PF mirror rules configuration*/
 };
 
index da915db..4be17f1 100644 (file)
@@ -2811,7 +2811,7 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
 
 int
 rte_eth_mirror_rule_set(uint8_t port_id,
-                       struct rte_eth_vmdq_mirror_conf *mirror_conf,
+                       struct rte_eth_mirror_conf *mirror_conf,
                        uint8_t rule_id, uint8_t on)
 {
        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
@@ -2834,12 +2834,6 @@ rte_eth_mirror_rule_set(uint8_t port_id,
                return -EINVAL;
        }
 
-       if (rule_id >= ETH_VMDQ_NUM_MIRROR_RULE) {
-               PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
-                       ETH_VMDQ_NUM_MIRROR_RULE - 1);
-               return -EINVAL;
-       }
-
        dev = &rte_eth_devices[port_id];
        FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
 
@@ -2853,12 +2847,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 
        VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
-       if (rule_id >= ETH_VMDQ_NUM_MIRROR_RULE) {
-               PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
-                       ETH_VMDQ_NUM_MIRROR_RULE-1);
-               return -EINVAL;
-       }
-
        dev = &rte_eth_devices[port_id];
        FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
 
index aed09f4..7d7fc2e 100644 (file)
@@ -467,8 +467,8 @@ struct rte_eth_rss_conf {
 #define ETH_VMDQ_ACCEPT_BROADCAST   0x0008 /**< accept broadcast packets. */
 #define ETH_VMDQ_ACCEPT_MULTICAST   0x0010 /**< multicast promiscuous. */
 
-/* Definitions used for VMDQ mirror rules setting */
-#define ETH_VMDQ_NUM_MIRROR_RULE     4 /**< Maximum nb. of mirror rules. . */
+/** Maximum nb. of vlan per mirror rule */
+#define ETH_MIRROR_MAX_VLANS       64
 
 #define ETH_VMDQ_POOL_MIRROR    0x0001 /**< Virtual Pool Mirroring. */
 #define ETH_VMDQ_UPLINK_MIRROR  0x0002 /**< Uplink Port Mirroring. */
@@ -480,18 +480,19 @@ struct rte_eth_rss_conf {
  */
 struct rte_eth_vlan_mirror {
        uint64_t vlan_mask; /**< mask for valid VLAN ID. */
-       uint16_t vlan_id[ETH_VMDQ_MAX_VLAN_FILTERS];
-       /** VLAN ID list for vlan mirror. */
+       /** VLAN ID list for vlan mirroring. */
+       uint16_t vlan_id[ETH_MIRROR_MAX_VLANS];
 };
 
 /**
  * A structure used to configure traffic mirror of an Ethernet port.
  */
-struct rte_eth_vmdq_mirror_conf {
+struct rte_eth_mirror_conf {
        uint8_t rule_type_mask; /**< Mirroring rule type mask we want to set */
-       uint8_t dst_pool; /**< Destination pool for this mirror rule. */
+       uint8_t dst_pool;  /**< Destination pool for this mirror rule. */
        uint64_t pool_mask; /**< Bitmap of pool for pool mirroring */
-       struct rte_eth_vlan_mirror vlan; /**< VLAN ID setting for VLAN mirroring */
+       /** VLAN ID setting for VLAN mirroring. */
+       struct rte_eth_vlan_mirror vlan;
 };
 
 /**
@@ -1215,7 +1216,7 @@ typedef int (*eth_set_vf_rate_limit_t)(struct rte_eth_dev *dev,
 /**< @internal Set VF TX rate */
 
 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
-                                 struct rte_eth_vmdq_mirror_conf *mirror_conf,
+                                 struct rte_eth_mirror_conf *mirror_conf,
                                  uint8_t rule_id,
                                  uint8_t on);
 /**< @internal Add a traffic mirroring rule on an Ethernet device */
@@ -3176,7 +3177,7 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
  *   - (-EINVAL) if the mr_conf information is not correct.
  */
 int rte_eth_mirror_rule_set(uint8_t port_id,
-                       struct rte_eth_vmdq_mirror_conf *mirror_conf,
+                       struct rte_eth_mirror_conf *mirror_conf,
                        uint8_t rule_id,
                        uint8_t on);