From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id BF2ED7CF0 for ; Mon, 4 Sep 2017 17:22:58 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2017 08:22:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,475,1498546800"; d="scan'208";a="125438373" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga004.jf.intel.com with ESMTP; 04 Sep 2017 08:22:45 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.167]) by irsmsx110.ger.corp.intel.com ([163.33.3.25]) with mapi id 14.03.0319.002; Mon, 4 Sep 2017 16:22:45 +0100 From: "Rybalchenko, Kirill" To: Rongqiang XIE , "Wu, Jingjing" , "Doherty, Declan" , "thomas@monjalon.net" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4] app/testpmd:add bond type description Thread-Index: AQHTIIUYJJjOZfrAjUGDLR21/P6ktKKk4Qag Date: Mon, 4 Sep 2017 15:22:44 +0000 Message-ID: <696B43C21188DF4F9C9091AAE4789B824E295D3F@IRSMSX108.ger.corp.intel.com> References: <1503983327-2017-1-git-send-email-xie.rongqiang@zte.com.cn> In-Reply-To: <1503983327-2017-1-git-send-email-xie.rongqiang@zte.com.cn> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTRmYTIxZGYtZTk1ZC00OWViLTgzNzQtOWVlZmQ2Y2FjOWQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImRDODhrV2JCYUhBXC8zaTIxS2p5QWxkaW14Um1aZHI4TjZabmlaeElFXC9vWT0ifQ== x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4] app/testpmd:add bond type description X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2017 15:22:59 -0000 Hi, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Rongqiang XIE > Sent: Tuesday 29 August 2017 06:09 > To: Wu, Jingjing ; Doherty, Declan > ; thomas@monjalon.net > Cc: dev@dpdk.org; Rongqiang XIE > Subject: [dpdk-dev] [PATCH v4] app/testpmd:add bond type description >=20 > In function cmd_show_bonding_config_parsed() used number represent > the bond type,in order more detailed,add bond type description otherwise > we may confused about the number type. > And also,the primary port just use in mode active backup and tlb, so,when > the mode is active backup or tlb show the primary port info may be more > appropriate. >=20 > Signed-off-by: Rongqiang XIE > --- > app/test-pmd/cmdline.c | 26 +++++++++++------- > drivers/net/bonding/rte_eth_bond.h | 15 +++++++++++ > drivers/net/bonding/rte_eth_bond_api.c | 40 > ++++++++++++++++++++++++++++ > drivers/net/bonding/rte_eth_bond_version.map | 1 + > 4 files changed, 73 insertions(+), 9 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > cd8c358..8395e02 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -4593,6 +4593,7 @@ static void cmd_show_bonding_config_parsed(void > *parsed_result, { > struct cmd_show_bonding_config_result *res =3D parsed_result; > int bonding_mode, agg_mode; > + char bonding_str[BONDING_MODE_STRING_LEN]; > uint8_t slaves[RTE_MAX_ETHPORTS]; > int num_slaves, num_active_slaves; > int primary_id; > @@ -4600,13 +4601,17 @@ static void > cmd_show_bonding_config_parsed(void *parsed_result, > portid_t port_id =3D res->port_id; >=20 > /* Display the bonding mode.*/ > + if (!rte_eth_bond_mode_string_get(port_id, bonding_str)) { > + printf("\tFailed to get bonding mode string for port =3D %d\n", > port_id); > + return; > + } > + printf("\tBonding mode: %s\n", bonding_str); > + > bonding_mode =3D rte_eth_bond_mode_get(port_id); > if (bonding_mode < 0) { > printf("\tFailed to get bonding mode for port =3D %d\n", > port_id); > return; > - } else > - printf("\tBonding mode: %d\n", bonding_mode); > - > + } > if (bonding_mode =3D=3D BONDING_MODE_BALANCE) { > int balance_xmit_policy; >=20 > @@ -4685,13 +4690,16 @@ static void > cmd_show_bonding_config_parsed(void *parsed_result, > printf("\tActive Slaves: []\n"); >=20 > } > - > - primary_id =3D rte_eth_bond_primary_get(port_id); > - if (primary_id < 0) { > - printf("\tFailed to get primary slave for port =3D %d\n", > port_id); > - return; > - } else > + if (bonding_mode =3D=3D BONDING_MODE_ACTIVE_BACKUP || > + bonding_mode =3D=3D BONDING_MODE_TLB){ > + primary_id =3D rte_eth_bond_primary_get(port_id); > + if (primary_id < 0) { > + printf("\tFailed to get primary slave for port =3D %d\n", > port_id); > + return; > + } > printf("\tPrimary: [%d]\n", primary_id); > + } > + return; >=20 > } >=20 > diff --git a/drivers/net/bonding/rte_eth_bond.h > b/drivers/net/bonding/rte_eth_bond.h > index 8efbf07..c25293a 100644 > --- a/drivers/net/bonding/rte_eth_bond.h > +++ b/drivers/net/bonding/rte_eth_bond.h > @@ -117,6 +117,9 @@ > #define BALANCE_XMIT_POLICY_LAYER34 (2) > /**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */ >=20 > +/* Max length size for bond mode string */ > +#define BONDING_MODE_STRING_LEN (30) > + > /** > * Create a bonded rte_eth_dev device > * > @@ -189,6 +192,18 @@ > rte_eth_bond_mode_get(uint8_t bonded_port_id); >=20 > /** > + * Get link bonding mode string of bonded device > + * > + * @param bonded_port_id Port ID of bonded device. > + * > + * @param mode mode string > + * @return > + * link bonding mode on success, negative value otherwise > + */ > +int > +rte_eth_bond_mode_string_get(uint8_t bonded_port_id, char *mode); > + > +/** > * Set slave rte_eth_dev as primary slave of bonded device > * > * @param bonded_port_id Port ID of bonded device. > diff --git a/drivers/net/bonding/rte_eth_bond_api.c > b/drivers/net/bonding/rte_eth_bond_api.c > index de1d9e0..c55b90f 100644 > --- a/drivers/net/bonding/rte_eth_bond_api.c > +++ b/drivers/net/bonding/rte_eth_bond_api.c > @@ -510,6 +510,46 @@ > } >=20 > int > +rte_eth_bond_mode_string_get(uint8_t bonded_port_id, char *mode) { > + struct bond_dev_private *internals; > + > + if (valid_bonded_port_id(bonded_port_id) !=3D 0) > + return -1; > + > + internals =3D rte_eth_devices[bonded_port_id].data->dev_private; > + > + switch (internals->mode) { > + case BONDING_MODE_ROUND_ROBIN: > + memcpy(mode, "round-robin", > BONDING_MODE_STRING_LEN); This code might generate segmentation fault, as memcpy will request memory = outside source buffer. Would you consider using strncpy instead? The same for all subsequent memcpys in this function. > + break; > + case BONDING_MODE_ACTIVE_BACKUP: > + memcpy(mode, "active-backup", > BONDING_MODE_STRING_LEN); > + break; > + case BONDING_MODE_BALANCE: > + memcpy(mode, "link-aggregation", > BONDING_MODE_STRING_LEN); > + break; > + case BONDING_MODE_BROADCAST: > + memcpy(mode, "broadcast", > BONDING_MODE_STRING_LEN); > + break; > + case BONDING_MODE_8023AD: > + memcpy(mode, "link-aggregation-802.3ad", > BONDING_MODE_STRING_LEN); > + break; > + case BONDING_MODE_TLB: > + memcpy(mode, "transmit-load-balancing", > BONDING_MODE_STRING_LEN); > + break; > + case BONDING_MODE_ALB: > + memcpy(mode, "adaptive-load-balancing", > BONDING_MODE_STRING_LEN); > + break; > + default: > + memcpy(mode, "unknown-mode", > BONDING_MODE_STRING_LEN); > + break; > + } > + > + return 0; > +} > + > +int > rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id) > { > struct bond_dev_private *internals; > diff --git a/drivers/net/bonding/rte_eth_bond_version.map > b/drivers/net/bonding/rte_eth_bond_version.map > index 0f4e847..c08f60e 100644 > --- a/drivers/net/bonding/rte_eth_bond_version.map > +++ b/drivers/net/bonding/rte_eth_bond_version.map > @@ -53,6 +53,7 @@ DPDK_17.08 { > rte_eth_bond_8023ad_agg_selection_set; > rte_eth_bond_8023ad_conf_get; > rte_eth_bond_8023ad_setup; > + rte_eth_bond_mode_string_get; >=20 >=20 > } DPDK_16.07; > -- > 1.8.3.1 >=20