net: add rte prefix to ether structures
[dpdk.git] / examples / vm_power_manager / channel_monitor.c
index 74df0fe..1194f62 100644 (file)
@@ -56,12 +56,12 @@ static struct policy policies[MAX_CLIENTS];
 #ifdef USE_JANSSON
 
 union PFID {
-       struct ether_addr addr;
+       struct rte_ether_addr addr;
        uint64_t pfid;
 };
 
 static int
-str_to_ether_addr(const char *a, struct ether_addr *ether_addr)
+str_to_ether_addr(const char *a, struct rte_ether_addr *ether_addr)
 {
        int i;
        char *end;
@@ -159,7 +159,8 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
                        if (ret)
                                return ret;
                } else if (!strcmp(key, "name")) {
-                       strcpy(pkt->vm_name, json_string_value(value));
+                       strlcpy(pkt->vm_name, json_string_value(value),
+                                       sizeof(pkt->vm_name));
                } else if (!strcmp(key, "command")) {
                        char command[32];
                        strlcpy(command, json_string_value(value), 32);
@@ -403,7 +404,7 @@ get_pfid(struct policy *pol)
 
                RTE_ETH_FOREACH_DEV(x) {
                        ret = rte_pmd_i40e_query_vfid_by_mac(x,
-                               (struct ether_addr *)&(pol->pkt.vfid[i]));
+                               (struct rte_ether_addr *)&(pol->pkt.vfid[i]));
                        if (ret != -EINVAL) {
                                pol->port[i] = x;
                                break;
@@ -437,9 +438,12 @@ update_policy(struct channel_packet *pkt)
                        /* Copy the contents of *pkt into the policy.pkt */
                        policies[i].pkt = *pkt;
                        get_pcpu_to_control(&policies[i]);
-                       if (get_pfid(&policies[i]) < 0) {
-                               updated = 1;
-                               break;
+                       /* Check Eth dev only for Traffic policy */
+                       if (policies[i].pkt.policy_to_use == TRAFFIC) {
+                               if (get_pfid(&policies[i]) < 0) {
+                                       updated = 1;
+                                       break;
+                               }
                        }
                        core_share_status(i);
                        policies[i].enabled = 1;
@@ -451,8 +455,13 @@ update_policy(struct channel_packet *pkt)
                        if (policies[i].enabled == 0) {
                                policies[i].pkt = *pkt;
                                get_pcpu_to_control(&policies[i]);
-                               if (get_pfid(&policies[i]) < 0)
-                                       break;
+                               /* Check Eth dev only for Traffic policy */
+                               if (policies[i].pkt.policy_to_use == TRAFFIC) {
+                                       if (get_pfid(&policies[i]) < 0) {
+                                               updated = 1;
+                                               break;
+                                       }
+                               }
                                core_share_status(i);
                                policies[i].enabled = 1;
                                break;
@@ -807,18 +816,13 @@ read_json_packet(struct channel_info *chan_info)
                                indent--;
                        if ((indent > 0) || (idx > 0))
                                idx++;
-                       if (indent == 0)
+                       if (indent <= 0)
                                json_data[idx] = 0;
                        if (idx >= MAX_JSON_STRING_LEN-1)
                                break;
                } while (indent > 0);
 
-               if (indent > 0)
-                       /*
-                        * We've broken out of the read loop without getting
-                        * a closing brace, so throw away the data
-                        */
-                       json_data[idx] = 0;
+               json_data[idx] = '\0';
 
                if (strlen(json_data) == 0)
                        continue;