DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac
@ 2016-08-16 15:15 Alejandro Lucero
  2016-09-13 17:10 ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Lucero @ 2016-08-16 15:15 UTC (permalink / raw)
  To: dev

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfp_net.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 82e3e4e..45d122d 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -607,18 +607,8 @@ nfp_net_rx_freelist_setup(struct rte_eth_dev *dev)
 static void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-	uint32_t *mac_address;
-
 	nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
 	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
-
-	/* A MAC address is 8 bytes long */
-	mac_address = (uint32_t *)(hw->mac_addr);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_MACADDR,
-		      rte_cpu_to_be_32(*mac_address));
-	nn_cfg_writel(hw, NFP_NET_CFG_MACADDR + 4,
-		      rte_cpu_to_be_32(*(mac_address + 4)));
 }
 
 static void
@@ -627,6 +617,17 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 	hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
+static void nfp_net_read_mac(struct nfp_net_hw *hw) {
+
+	uint32_t tmp;
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	memcpy(&hw->mac_addr[0], &tmp, sizeof(struct ether_addr));
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	memcpy(&hw->mac_addr[4], &tmp, 2);
+}
+
 static int
 nfp_net_start(struct rte_eth_dev *dev)
 {
@@ -2413,8 +2414,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 		return -ENOMEM;
 	}
 
-	/* Using random mac addresses for VFs */
-	eth_random_addr(&hw->mac_addr[0]);
+	nfp_net_read_mac(hw);
+
+	if (!is_valid_assigned_ether_addr((struct ether_addr *)&hw->mac_addr[0]))
+		/* Using random mac addresses for VFs */
+		eth_random_addr(&hw->mac_addr[0]);
 
 	/* Copying mac address to DPDK eth_dev struct */
 	ether_addr_copy(&eth_dev->data->mac_addrs[0],
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac
  2016-08-16 15:15 [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac Alejandro Lucero
@ 2016-09-13 17:10 ` Ferruh Yigit
  2016-09-13 17:15   ` Ferruh Yigit
  2016-09-13 19:30   ` Thomas Monjalon
  0 siblings, 2 replies; 5+ messages in thread
From: Ferruh Yigit @ 2016-09-13 17:10 UTC (permalink / raw)
  To: Alejandro Lucero, dev

Hi Alejandro,

On 8/16/2016 4:15 PM, Alejandro Lucero wrote:
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> ---

There are following checkpatch warnings, also check-git-log complains:

Headline too long:
        nfp: unregister interrupt callback function when closing device

...

>  
> +static void nfp_net_read_mac(struct nfp_net_hw *hw) {
> +

ERROR:OPEN_BRACE: open brace '{' following function declarations go on
the next line
#45: FILE: drivers/net/nfp/nfp_net.c:620:
+static void nfp_net_read_mac(struct nfp_net_hw *hw) {

...

> +	if (!is_valid_assigned_ether_addr((struct ether_addr *)&hw->mac_addr[0]))

WARNING:LONG_LINE: line over 80 characters
#67: FILE: drivers/net/nfp/nfp_net.c:2419:
+       if (!is_valid_assigned_ether_addr((struct ether_addr
*)&hw->mac_addr[0]))

> +		/* Using random mac addresses for VFs */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac
  2016-09-13 17:10 ` Ferruh Yigit
@ 2016-09-13 17:15   ` Ferruh Yigit
  2016-09-13 19:30   ` Thomas Monjalon
  1 sibling, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2016-09-13 17:15 UTC (permalink / raw)
  To: Alejandro Lucero, dev

On 9/13/2016 6:10 PM, Ferruh Yigit wrote:
> Hi Alejandro,
> 
> On 8/16/2016 4:15 PM, Alejandro Lucero wrote:
>> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
>> ---
> 
> There are following checkpatch warnings, also check-git-log complains:
> 
> Headline too long:
>         nfp: unregister interrupt callback function when closing device
> 

copy-paste error, this one gives following, again because of "mac" usage:

Wrong headline lowercase:
        nfp: using random mac address if not a configured mac


> ...
> 
>>  
>> +static void nfp_net_read_mac(struct nfp_net_hw *hw) {
>> +
> 
> ERROR:OPEN_BRACE: open brace '{' following function declarations go on
> the next line
> #45: FILE: drivers/net/nfp/nfp_net.c:620:
> +static void nfp_net_read_mac(struct nfp_net_hw *hw) {
> 
> ...
> 
>> +	if (!is_valid_assigned_ether_addr((struct ether_addr *)&hw->mac_addr[0]))
> 
> WARNING:LONG_LINE: line over 80 characters
> #67: FILE: drivers/net/nfp/nfp_net.c:2419:
> +       if (!is_valid_assigned_ether_addr((struct ether_addr
> *)&hw->mac_addr[0]))
> 
>> +		/* Using random mac addresses for VFs */
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac
  2016-09-13 17:10 ` Ferruh Yigit
  2016-09-13 17:15   ` Ferruh Yigit
@ 2016-09-13 19:30   ` Thomas Monjalon
  2016-09-16  7:49     ` Alejandro Lucero
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2016-09-13 19:30 UTC (permalink / raw)
  To: Alejandro Lucero; +Cc: dev, Ferruh Yigit

2016-09-13 18:10, Ferruh Yigit:
> Hi Alejandro,
> 
> On 8/16/2016 4:15 PM, Alejandro Lucero wrote:
> > Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> > ---
> 
> There are following checkpatch warnings, also check-git-log complains:
> 
> Headline too long:
>         nfp: unregister interrupt callback function when closing device

Just a tip to keep headlines short: you can often remove some common words.
Here we still understand the idea without "function" and "device".
	nfp: unregister interrupt callback when closing

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac
  2016-09-13 19:30   ` Thomas Monjalon
@ 2016-09-16  7:49     ` Alejandro Lucero
  0 siblings, 0 replies; 5+ messages in thread
From: Alejandro Lucero @ 2016-09-16  7:49 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Ferruh Yigit

Thank you for the feedback.

I'll send the fixed patched today.



On Tue, Sep 13, 2016 at 8:30 PM, Thomas Monjalon <thomas.monjalon@6wind.com>
wrote:

> 2016-09-13 18:10, Ferruh Yigit:
> > Hi Alejandro,
> >
> > On 8/16/2016 4:15 PM, Alejandro Lucero wrote:
> > > Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> > > ---
> >
> > There are following checkpatch warnings, also check-git-log complains:
> >
> > Headline too long:
> >         nfp: unregister interrupt callback function when closing device
>
> Just a tip to keep headlines short: you can often remove some common words.
> Here we still understand the idea without "function" and "device".
>         nfp: unregister interrupt callback when closing
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-16  7:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 15:15 [dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac Alejandro Lucero
2016-09-13 17:10 ` Ferruh Yigit
2016-09-13 17:15   ` Ferruh Yigit
2016-09-13 19:30   ` Thomas Monjalon
2016-09-16  7:49     ` Alejandro Lucero

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).