From patchwork Thu Aug 24 10:55:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie RongQiang X-Patchwork-Id: 27851 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EE2917D24; Thu, 24 Aug 2017 12:56:44 +0200 (CEST) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.217.80.70]) by dpdk.org (Postfix) with ESMTP id C20477D22 for ; Thu, 24 Aug 2017 12:56:41 +0200 (CEST) X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170824185622 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 24 Aug 2017 10:56:22 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v7OAuNTT000835; Thu, 24 Aug 2017 18:56:23 +0800 (GMT-8) (envelope-from xie.rongqiang@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.43.166.171]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017082418562911-707768 ; Thu, 24 Aug 2017 18:56:29 +0800 From: Rongqiang XIE To: declan.doherty@intel.com Cc: dev@dpdk.org, Rongqiang XIE Date: Thu, 24 Aug 2017 18:55:46 +0800 Message-Id: <1503572146-15264-1-git-send-email-xie.rongqiang@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-08-24 18:56:29, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2017-08-24 18:56:12, Serialize complete at 2017-08-24 18:56:12 X-MAIL: mse01.zte.com.cn v7OAuNTT000835 X-HQIP: 127.0.0.1 Subject: [dpdk-dev] [PATCH] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Rongqiang XIE --- app/test-pmd/cmdline.c | 29 +++++++++++++++---------- drivers/net/bonding/rte_eth_bond.h | 15 +++++++++++++ drivers/net/bonding/rte_eth_bond_api.c | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index cd8c358..c386a63 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 = 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 = res->port_id; /* Display the bonding mode.*/ - bonding_mode = rte_eth_bond_mode_get(port_id); - if (bonding_mode < 0) { - printf("\tFailed to get bonding mode for port = %d\n", port_id); + if (!rte_eth_bond_mode_string_get(port_id, bonding_str)) { + printf("\tFailed to get bonding mode string for port = %d\n", port_id); return; } else - printf("\tBonding mode: %d\n", bonding_mode); + printf("\tBonding mode: %s\n", bonding_str); + bonding_mode = rte_eth_bond_mode_get(port_id); + if (bonding_mode < 0) { + printf("\tFailed to get bonding mode for port = %d\n", port_id); + return; + } if (bonding_mode == BONDING_MODE_BALANCE) { int balance_xmit_policy; @@ -4685,13 +4690,15 @@ static void cmd_show_bonding_config_parsed(void *parsed_result, printf("\tActive Slaves: []\n"); } - - primary_id = rte_eth_bond_primary_get(port_id); - if (primary_id < 0) { - printf("\tFailed to get primary slave for port = %d\n", port_id); - return; - } else - printf("\tPrimary: [%d]\n", primary_id); + if (bonding_mode == BONDING_MODE_ACTIVE_BACKUP || + bonding_mode == BONDING_MODE_TLB){ + primary_id = rte_eth_bond_primary_get(port_id); + if (primary_id < 0) { + printf("\tFailed to get primary slave for port = %d\n", port_id); + return; + } else + printf("\tPrimary: [%d]\n", primary_id); + } } 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 */ +/* 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); /** + * 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..5ba097c 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -510,6 +510,45 @@ } 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) != 0) + return -1; + + internals = 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); + 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); + } + + return 0; +} + +int rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id) { struct bond_dev_private *internals;