From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91649A0552; Tue, 6 Dec 2022 03:01:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AD4040156; Tue, 6 Dec 2022 03:01:17 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 803E140151 for ; Tue, 6 Dec 2022 03:01:15 +0100 (CET) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NR3XM5L9NzmWPj; Tue, 6 Dec 2022 10:00:19 +0800 (CST) Received: from [10.78.134.87] (10.78.134.87) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Dec 2022 10:01:07 +0800 Message-ID: Date: Tue, 6 Dec 2022 10:01:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH 1/2] net/bonding: support private dump ops To: Chengwen Feng , , CC: , References: <20221205081051.25905-1-fengchengwen@huawei.com> <20221205081051.25905-2-fengchengwen@huawei.com> From: "humin (Q)" In-Reply-To: <20221205081051.25905-2-fengchengwen@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.78.134.87] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi, 在 2022/12/5 16:10, Chengwen Feng 写道: > This patch implements eth_dev_priv_dump ops which could enhance the > debug capability. > > The dump output is similar to testpmd command > "show bonding config [port]". > > Signed-off-by: Chengwen Feng > --- > drivers/net/bonding/rte_eth_bond_pmd.c | 103 ++++++++++++++++++++++++- > 1 file changed, 102 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c > index b9bcebc6cb..80fb2dc462 100644 > --- a/drivers/net/bonding/rte_eth_bond_pmd.c > +++ b/drivers/net/bonding/rte_eth_bond_pmd.c > @@ -3329,6 +3329,106 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) > rte_spinlock_unlock(&internals->lock); > } > > +static const char * > +bond_mode_name(uint8_t mode) > +{ > + switch (mode) { > + case BONDING_MODE_ROUND_ROBIN: > + return "ROUND_ROBIN"; > + case BONDING_MODE_ACTIVE_BACKUP: > + return "ACTIVE_BACKUP"; > + case BONDING_MODE_BALANCE: > + return "BALANCE"; > + case BONDING_MODE_BROADCAST: > + return "BROADCAST"; > + case BONDING_MODE_8023AD: > + return "8023AD"; > + case BONDING_MODE_TLB: > + return "TLB"; > + case BONDING_MODE_ALB: > + return "ALB"; > + default: > + return "Unknown"; > + } > +} > + > +static int > +bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f) > +{ > + struct bond_dev_private instant_priv; > + const struct bond_dev_private *internals = &instant_priv; > + int bonding_mode; > + int i; > + > + /* Obtain a instance of dev_private to prevent data from being modified. */ > + memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private)); > + bonding_mode = internals->mode; > + > + fprintf(f, " - Dev basic:\n"); > + fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(bonding_mode), bonding_mode); data type of“bonding mode”does not match "mode". > + > + if (bonding_mode == BONDING_MODE_BALANCE || > + bonding_mode == BONDING_MODE_8023AD) { > + fprintf(f, "\tBalance Xmit Policy: "); > + switch (internals->balance_xmit_policy) { > + case BALANCE_XMIT_POLICY_LAYER2: > + fprintf(f, "BALANCE_XMIT_POLICY_LAYER2"); > + break; > + case BALANCE_XMIT_POLICY_LAYER23: > + fprintf(f, "BALANCE_XMIT_POLICY_LAYER23"); > + break; > + case BALANCE_XMIT_POLICY_LAYER34: > + fprintf(f, "BALANCE_XMIT_POLICY_LAYER34"); > + break; > + } why no "default case" ? > + fprintf(f, "\n"); > + } > + > + if (bonding_mode == BONDING_MODE_8023AD) { > + fprintf(f, "\tIEEE802.3AD Aggregator Mode: "); > + switch (internals->mode4.agg_selection) { > + case AGG_BANDWIDTH: > + fprintf(f, "bandwidth"); > + break; > + case AGG_STABLE: > + fprintf(f, "stable"); > + break; > + case AGG_COUNT: > + fprintf(f, "count"); > + break; > + } same as above. > + fprintf(f, "\n"); > + } > + > + if (internals->slave_count > 0) { > + fprintf(f, "\tSlaves (%u): [", internals->slave_count); > + for (i = 0; i < internals->slave_count - 1; i++) > + fprintf(f, "%u ", internals->slaves[i].port_id); > + > + fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id); > + } else { > + fprintf(f, "\tSlaves: []\n"); > + } > + > + if (internals->active_slave_count > 0) { > + fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count); > + for (i = 0; i < internals->active_slave_count - 1; i++) > + fprintf(f, "%u ", internals->active_slaves[i]); > + > + fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]); > + > + } else { > + fprintf(f, "\tActive Slaves: []\n"); > + } > + > + if (internals->user_defined_primary_port) > + fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port); > + if (internals->slave_count > 0) > + fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port); > + > + return 0; > +} > + > const struct eth_dev_ops default_dev_ops = { > .dev_start = bond_ethdev_start, > .dev_stop = bond_ethdev_stop, > @@ -3355,7 +3455,8 @@ const struct eth_dev_ops default_dev_ops = { > .mac_addr_set = bond_ethdev_mac_address_set, > .mac_addr_add = bond_ethdev_mac_addr_add, > .mac_addr_remove = bond_ethdev_mac_addr_remove, > - .flow_ops_get = bond_flow_ops_get > + .flow_ops_get = bond_flow_ops_get, > + .eth_dev_priv_dump = bond_ethdev_priv_dump > }; > > static int