From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id 7C7817CDA for ; Wed, 13 Feb 2019 09:03:01 +0100 (CET) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x1D830He030479; Wed, 13 Feb 2019 17:03:00 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id E99F0638E12; Wed, 13 Feb 2019 17:02:59 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id DE3C6638C17; Wed, 13 Feb 2019 17:02:59 +0900 (JST) Received: from [IPv6:::1] (watercress.nslab.ecl.ntt.co.jp [129.60.13.73]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id D92FE400967; Wed, 13 Feb 2019 17:02:59 +0900 (JST) References: <201902120929.x1C9Tk2I004619@imss04.silk.ntt-tx.co.jp> From: Yasufumi Ogawa Message-ID: <38cb288a-3c44-e614-85d6-7546da9f036c@lab.ntt.co.jp> Date: Wed, 13 Feb 2019 17:00:48 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <201902120929.x1C9Tk2I004619@imss04.silk.ntt-tx.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: x-fn-spp@sl.ntt-tx.co.jp Cc: ferruh.yigit@intel.com, spp@dpdk.org X-TM-AS-MML: disable Subject: Re: [spp] [PATCH] spp_vf: fix unexpected count up for bad request 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: , X-List-Received-Date: Wed, 13 Feb 2019 08:03:02 -0000 > From: Hideyuki Yamashita > > The num of ports is counted up while port is not added actually if it > is already reached to the defiend muximum number. This patch is to fix > the issue by rejecting the count up. Applied, thanks. > > Signed-off-by: Hideyuki Yamashita > Signed-off-by: Naoki Takada > --- > src/vf/common/command_proc.c | 56 +++++++++++++++++++++++++++++++++++- > 1 file changed, 55 insertions(+), 1 deletion(-) > > diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c > index 0f99827..415a638 100644 > --- a/src/vf/common/command_proc.c > +++ b/src/vf/common/command_proc.c > @@ -321,7 +321,55 @@ spp_update_component( > return ret; > } > > +/* Check if over the maximum num of rx and tx ports of component. */ > +static int > +check_port_count(int component_type, enum spp_port_rxtx rxtx, int num_rx, > + int num_tx) > +{ > + RTE_LOG(INFO, SPP_COMMAND_PROC, "port count, port_type=%d," > + " rx=%d, tx=%d\n", rxtx, num_rx, num_tx); > + if (rxtx == SPP_PORT_RXTX_RX) > + num_rx++; > + else > + num_tx++; > + /* Add rx or tx port appointed in port_type. */ > + RTE_LOG(INFO, SPP_COMMAND_PROC, "Num of ports after count up," > + " port_type=%d, rx=%d, tx=%d\n", > + rxtx, num_rx, num_tx); > + switch (component_type) { > + case SPP_COMPONENT_FORWARD: > + if (num_rx > 1 || num_tx > 1) > + return SPP_RET_NG; > + break; > + > + case SPP_COMPONENT_MERGE: > + if (num_tx > 1) > + return SPP_RET_NG; > + break; > + > + case SPP_COMPONENT_CLASSIFIER_MAC: > + if (num_rx > 1) > + return SPP_RET_NG; > + break; > + > + case SPP_COMPONENT_MIRROR: > + if (num_rx > 1 || num_tx > 2) > + return SPP_RET_NG; > + break; > + > + default: > + /* Illegal component type. */ > + return SPP_RET_NG; > + } > + > + return SPP_RET_OK; > +} > + > /* Port add or del to execute it */ > +/** > + * TODO(Ogasawara) The name `action` should be revised to be more > + * appropriate one. > + */ > static int > spp_update_port(enum spp_command_action action, > const struct spp_port_index *port, > @@ -361,8 +409,14 @@ spp_update_port(enum spp_command_action action, > > switch (action) { > case SPP_CMD_ACTION_ADD: > + /* Check if over the maximum num of ports of component. */ > + if (check_port_count(comp_info->type, rxtx, > + comp_info->num_rx_port, > + comp_info->num_tx_port) != SPP_RET_OK) > + return SPP_RET_NG; > + > ret_check = check_port_element(port_info, *num, ports); > - /* registered check */ > + /* Check whether a port has been already registered. */ > if (ret_check >= SPP_RET_OK) { > /* registered */ > if (ability->ope == SPP_PORT_ABILITY_OPE_ADD_VLANTAG) { > -- Yasufumi Ogawa NTT Network Service Systems Labs