From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88233A317C for ; Thu, 17 Oct 2019 14:58:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04F4B1E989; Thu, 17 Oct 2019 14:58:33 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by dpdk.org (Postfix) with ESMTP id 39BB31E993 for ; Thu, 17 Oct 2019 14:58:31 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id d22so1113843pls.0 for ; Thu, 17 Oct 2019 05:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=tkcOn9MpasWVvNdG2VTM5gCz3pJdku/LrGaUwxzuoHQ=; b=JOVT5ZIzzC7Ixe+qPV756ZfHSd85UP52Nq4cNOHHB1MQxmPYsc8MhcmUCaM0UnETcu UTs9xafQ47cPfqSBdg7sUeJxe5MgNGfYoGhzBLnELQCm3HMlMk92Lh5EYSzq27GyLO8V 2O0rtEmQ9Y/N8WQR37NjaZjIZOIm4NHifLxpTJxBZXX/7KhVVrhbBFqVztdSQ1ptnVZm tkE0TM6FRL3pSYbat1ZnlUMlDz9DdWFGaw1evDWENumUDpD+MIYH1oT5IZr5yvFTaCiy C4Q/FOmmzlKo2H1Lc/ft7r2rV1AtsB9+p0VCz/Sw2HLoEEOtUjRudYDNCnGWuMaS6M89 8LdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=tkcOn9MpasWVvNdG2VTM5gCz3pJdku/LrGaUwxzuoHQ=; b=tHDfjZRoEaHukTvTCdGeOAWr6bKoDe0oFubxUgLCoB5Naov7TddW3oqDDfNWyTe3Ry OrJSwP9u6qzY+KvyG1R29Bk7gy1wJ7hgn0SkNVscqI8O7EpMUpig38KNEj+Y6iRZdKgz /tn1w4zG/LPm0vui16BKYDt2GDR93tVpG+CzytOtsLHMbXEilbItqEXHTCvcYx7OQhGF qgVd/BwPILAbpAJ1fPnpRgfZwyYk4o5Y5upGPhbb292M29W8wY1nHU1RHDMeRg7F5jL7 fD3CWOCZ1hyY8NwFp3zzroGYwvkduXddp43WgdlOETaSIOTZBdyUiFQNXCxUDbLyOGdp Vhlw== X-Gm-Message-State: APjAAAVsEMOGAVO5Jzqgl+Wf4L+G4CtRv78cmHoecjNJdXWZxRSxXI5I u2O9MwVIqeTJ4ueCdgvlqFG8MsgG8Rg= X-Google-Smtp-Source: APXvYqzQEPDM6obXAGNDarasZPGUywoCUFgm/4CCuSs6+aTCgQwMBagfESq2u/EMF3s0jn+Lv+LiAg== X-Received: by 2002:a17:902:8f8c:: with SMTP id z12mr4056993plo.36.1571317110187; Thu, 17 Oct 2019 05:58:30 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id x9sm6107822pje.27.2019.10.17.05.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Oct 2019 05:58:29 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Thu, 17 Oct 2019 21:58:22 +0900 Message-Id: <20191017125822.29309-3-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017125822.29309-1-yasufum.o@gmail.com> References: <20191017125822.29309-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 2/2] spp_primary: fix bug of add and del port X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa Added port cannot be referred because `port_fwd_array` is updated appropriately, and same issue for deleted port. This patch is to fix this issue by updating `port_fwd_array` in add_port() and del_port(). Signed-off-by: Yasufumi Ogawa --- src/cli/commands/pri.py | 40 ++++++++++++++++++++-------------------- src/nfv/commands.h | 4 ++++ src/primary/main.c | 13 +++++++++++++ 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py index 021f322..32c632c 100644 --- a/src/cli/commands/pri.py +++ b/src/cli/commands/pri.py @@ -61,7 +61,7 @@ class SppPrimary(object): # Print default error message pass else: - print('Error: unknown response.') + print('Error: unknown response from status.') elif subcmd == 'add': self._run_add(params) @@ -87,7 +87,7 @@ class SppPrimary(object): elif res.status_code in common_err_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for clear.') else: print('Invalid pri command!') @@ -102,7 +102,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for exit.') def print_status(self, json_obj): """Parse SPP primary's status and print. @@ -219,15 +219,15 @@ class SppPrimary(object): def _get_ports(self): """Get all of ports as a list.""" - res = self.spp_ctl_cli.get('primary') + res = self.spp_ctl_cli.get('primary/status') if res is not None: error_codes = self.spp_ctl_cli.rest_common_error_codes if res.status_code == 200: - return res.json()['ports'] + return res.json()['forwarder']['ports'] elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for get_ports.') def _get_patches(self): """Get all of patched ports as a list of dicts. @@ -237,15 +237,15 @@ class SppPrimary(object): {'src': 'ring:1', 'dst':'vhost:1'}, ...] """ - res = self.spp_ctl_cli.get('primary') + res = self.spp_ctl_cli.get('primary/status') if res is not None: error_codes = self.spp_ctl_cli.rest_common_error_codes if res.status_code == 200: - return res.json()['patches'] + return res.json()['forwarder']['patches'] elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for get_patches.') def _get_ports_and_patches(self): """Get all of ports and patchs at once. @@ -256,17 +256,17 @@ class SppPrimary(object): ports, patches = _get_ports_and_patches() """ - res = self.spp_ctl_cli.get('primary') + res = self.spp_ctl_cli.get('primary/status') if res is not None: error_codes = self.spp_ctl_cli.rest_common_error_codes if res.status_code == 200: - ports = res.json()['ports'] - patches = res.json()['patches'] + ports = res.json()['forwarder']['ports'] + patches = res.json()['forwarder']['patches'] return ports, patches elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response 3.') def _get_patched_ports(self): """Get all of patched ports as a list. @@ -547,7 +547,7 @@ class SppPrimary(object): # Print default error message pass else: - print('Error: unknown response.') + print('Error: unknown response for _get_sec_ids.') return sec_ids def _setup_opts_dict(self, opts_list): @@ -590,7 +590,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for add.') def _run_del(self, params): """Run `del` command.""" @@ -617,7 +617,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for del.') def _run_forward_or_stop(self, cmd): """Run `forward` or `stop` command.""" @@ -641,7 +641,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for forward/stop.') def _run_patch(self, params): """Run `patch` command.""" @@ -657,7 +657,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for patch.') else: if len(params) < 2: print('Dst port is required!') @@ -673,7 +673,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for patch.') def _run_launch(self, params, wait_time): """Launch secondary process. @@ -787,7 +787,7 @@ class SppPrimary(object): elif res.status_code in error_codes: pass else: - print('Error: unknown response.') + print('Error: unknown response for launch.') @classmethod def help(cls): diff --git a/src/nfv/commands.h b/src/nfv/commands.h index 499bdd4..4a6a170 100644 --- a/src/nfv/commands.h +++ b/src/nfv/commands.h @@ -12,6 +12,10 @@ #define RTE_LOGTYPE_SPP_NFV RTE_LOGTYPE_USER1 +/* TODO(yasufum): consider to rename find_port_id() to find_ethdev_id() + * defined in shared/port_manager.c + */ + static int do_del(char *p_type, int p_id) { diff --git a/src/primary/main.c b/src/primary/main.c index 9d216a0..dbae424 100644 --- a/src/primary/main.c +++ b/src/primary/main.c @@ -785,10 +785,12 @@ get_status_json(char *str) * Add a port to spp_primary. Port is given as a resource UID which is a * combination of port type and ID like as 'ring:0'. */ +/* TODO(yasufum) consider to merge do_add in nfv/commands.h */ static int add_port(char *p_type, int p_id) { uint16_t dev_id; + uint16_t port_id; int res = 0; uint16_t cnt = 0; @@ -822,6 +824,13 @@ add_port(char *p_type, int p_id) if (res < 0) return -1; + port_id = (uint16_t) res; + port_map[port_id].id = p_id; + port_map[port_id].port_type = port_id_list[cnt].type; + port_map[port_id].stats = &ports->client_stats[p_id]; + + /* Update ports_fwd_array with port id */ + ports_fwd_array[port_id].in_port_id = port_id; return 0; } @@ -850,6 +859,7 @@ find_ethdev_id(int p_id, enum port_type ptype) } /* Delete port. */ +/* TODO(yasufum) consider to merge do_del in nfv/commands.h */ static int del_port(char *p_type, int p_id) { @@ -884,6 +894,9 @@ del_port(char *p_type, int p_id) port_id_list[dev_id].port_id = PORT_RESET; port_id_list[dev_id].type = UNDEF; + forward_array_remove(dev_id); + port_map_init_one(dev_id); + return 0; } -- 2.17.1