diff mbox series

[net] cxgb4: use port number to set mac addr

Message ID 20241203144149.92032-1-anumula@chelsio.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] cxgb4: use port number to set mac addr | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 337 this patch: 337
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 131 this patch: 131
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-12-04--03-00 (tests: 760)

Commit Message

Anumula Murali Mohan Reddy Dec. 3, 2024, 2:41 p.m. UTC
t4_set_vf_mac_acl() uses pf to set mac addr, but t4vf_get_vf_mac_acl()
uses port number to get mac addr, this leads to error when an attempt
to set MAC address on VF's of PF2 and PF3.
This patch fixes the issue by using port number to set mac address.

Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      | 2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski Dec. 4, 2024, 3:09 a.m. UTC | #1
On Tue,  3 Dec 2024 20:11:49 +0530 Anumula Murali Mohan Reddy wrote:
> t4_set_vf_mac_acl() uses pf to set mac addr, but t4vf_get_vf_mac_acl()
> uses port number to get mac addr, this leads to error when an attempt
> to set MAC address on VF's of PF2 and PF3.
> This patch fixes the issue by using port number to set mac address.

Please add a Fixes tag pointing to the first commit where the issue can
be observed.
Michal Swiatkowski Dec. 4, 2024, 10:35 a.m. UTC | #2
On Tue, Dec 03, 2024 at 08:11:49PM +0530, Anumula Murali Mohan Reddy wrote:
> t4_set_vf_mac_acl() uses pf to set mac addr, but t4vf_get_vf_mac_acl()
> uses port number to get mac addr, this leads to error when an attempt
> to set MAC address on VF's of PF2 and PF3.
> This patch fixes the issue by using port number to set mac address.
> 
> Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
> Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
> ---
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      | 2 +-
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
>  drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      | 5 +++--
>  3 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> index 75bd69ff61a8..c7c2c15a1815 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> @@ -2076,7 +2076,7 @@ void t4_idma_monitor(struct adapter *adapter,
>  		     struct sge_idma_monitor_state *idma,
>  		     int hz, int ticks);
>  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> -		      unsigned int naddr, u8 *addr);
> +		      u8 start, unsigned int naddr, u8 *addr);
>  void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
>  		    u32 start_index, bool sleep_ok);
>  void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> index 97a261d5357e..bc3af0054406 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> @@ -3234,7 +3234,7 @@ static int cxgb4_mgmt_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
>  
>  	dev_info(pi->adapter->pdev_dev,
>  		 "Setting MAC %pM on VF %d\n", mac, vf);
> -	ret = t4_set_vf_mac_acl(adap, vf + 1, 1, mac);
> +	ret = t4_set_vf_mac_acl(adap, vf + 1, pi->lport, 1, mac);
>  	if (!ret)
>  		ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, mac);
>  	return ret;
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> index 76de55306c4d..175bf9b13058 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> @@ -10215,11 +10215,12 @@ int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size)
>   *	t4_set_vf_mac_acl - Set MAC address for the specified VF
>   *	@adapter: The adapter
>   *	@vf: one of the VFs instantiated by the specified PF
> + *	@start: The start port id associated with specified VF
>   *	@naddr: the number of MAC addresses
>   *	@addr: the MAC address(es) to be set to the specified VF
>   */
>  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> -		      unsigned int naddr, u8 *addr)
> +		      u8 start, unsigned int naddr, u8 *addr)
>  {
>  	struct fw_acl_mac_cmd cmd;
>  
> @@ -10234,7 +10235,7 @@ int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
>  	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
>  	cmd.nmac = naddr;
>  
> -	switch (adapter->pf) {
> +	switch (start) {
>  	case 3:
>  		memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
You can use ether_addr_copy().

Beside that and fixes tag:
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

>  		break;
> -- 
> 2.39.3
Anumula Murali Mohan Reddy Dec. 6, 2024, 6 a.m. UTC | #3
O Wednesday, December 12/04/24, 2024 at 16:05:46 +0530, Michal Swiatkowski wrote:
> On Tue, Dec 03, 2024 at 08:11:49PM +0530, Anumula Murali Mohan Reddy wrote:
> > t4_set_vf_mac_acl() uses pf to set mac addr, but t4vf_get_vf_mac_acl()
> > uses port number to get mac addr, this leads to error when an attempt
> > to set MAC address on VF's of PF2 and PF3.
> > This patch fixes the issue by using port number to set mac address.
> > 
> > Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
> > Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
> > ---
> >  drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      | 2 +-
> >  drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
> >  drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      | 5 +++--
> >  3 files changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > index 75bd69ff61a8..c7c2c15a1815 100644
> > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > @@ -2076,7 +2076,7 @@ void t4_idma_monitor(struct adapter *adapter,
> >  		     struct sge_idma_monitor_state *idma,
> >  		     int hz, int ticks);
> >  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> > -		      unsigned int naddr, u8 *addr);
> > +		      u8 start, unsigned int naddr, u8 *addr);
> >  void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
> >  		    u32 start_index, bool sleep_ok);
> >  void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
> > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > index 97a261d5357e..bc3af0054406 100644
> > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > @@ -3234,7 +3234,7 @@ static int cxgb4_mgmt_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
> >  
> >  	dev_info(pi->adapter->pdev_dev,
> >  		 "Setting MAC %pM on VF %d\n", mac, vf);
> > -	ret = t4_set_vf_mac_acl(adap, vf + 1, 1, mac);
> > +	ret = t4_set_vf_mac_acl(adap, vf + 1, pi->lport, 1, mac);
> >  	if (!ret)
> >  		ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, mac);
> >  	return ret;
> > diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > index 76de55306c4d..175bf9b13058 100644
> > --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > @@ -10215,11 +10215,12 @@ int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size)
> >   *	t4_set_vf_mac_acl - Set MAC address for the specified VF
> >   *	@adapter: The adapter
> >   *	@vf: one of the VFs instantiated by the specified PF
> > + *	@start: The start port id associated with specified VF
> >   *	@naddr: the number of MAC addresses
> >   *	@addr: the MAC address(es) to be set to the specified VF
> >   */
> >  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> > -		      unsigned int naddr, u8 *addr)
> > +		      u8 start, unsigned int naddr, u8 *addr)
> >  {
> >  	struct fw_acl_mac_cmd cmd;
> >  
> > @@ -10234,7 +10235,7 @@ int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> >  	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
> >  	cmd.nmac = naddr;
> >  
> > -	switch (adapter->pf) {
> > +	switch (start) {
> >  	case 3:
> >  		memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
> You can use ether_addr_copy().
> 
> Beside that and fixes tag:
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> 
> >  		break;
> > -- 
> > 2.39.3
there are multiple instances where memcpy needs to be replaced. I will
send a separate patch to replace memcpy with ethr_addr_copy().

Thanks
Michal Swiatkowski Dec. 6, 2024, 10:01 a.m. UTC | #4
On Fri, Dec 06, 2024 at 01:00:12AM -0500, Anumula Murali Mohan Reddy wrote:
> O Wednesday, December 12/04/24, 2024 at 16:05:46 +0530, Michal Swiatkowski wrote:
> > On Tue, Dec 03, 2024 at 08:11:49PM +0530, Anumula Murali Mohan Reddy wrote:
> > > t4_set_vf_mac_acl() uses pf to set mac addr, but t4vf_get_vf_mac_acl()
> > > uses port number to get mac addr, this leads to error when an attempt
> > > to set MAC address on VF's of PF2 and PF3.
> > > This patch fixes the issue by using port number to set mac address.
> > > 
> > > Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
> > > Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
> > > ---
> > >  drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      | 2 +-
> > >  drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
> > >  drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      | 5 +++--
> > >  3 files changed, 5 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > > index 75bd69ff61a8..c7c2c15a1815 100644
> > > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> > > @@ -2076,7 +2076,7 @@ void t4_idma_monitor(struct adapter *adapter,
> > >  		     struct sge_idma_monitor_state *idma,
> > >  		     int hz, int ticks);
> > >  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> > > -		      unsigned int naddr, u8 *addr);
> > > +		      u8 start, unsigned int naddr, u8 *addr);
> > >  void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
> > >  		    u32 start_index, bool sleep_ok);
> > >  void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
> > > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > > index 97a261d5357e..bc3af0054406 100644
> > > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> > > @@ -3234,7 +3234,7 @@ static int cxgb4_mgmt_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
> > >  
> > >  	dev_info(pi->adapter->pdev_dev,
> > >  		 "Setting MAC %pM on VF %d\n", mac, vf);
> > > -	ret = t4_set_vf_mac_acl(adap, vf + 1, 1, mac);
> > > +	ret = t4_set_vf_mac_acl(adap, vf + 1, pi->lport, 1, mac);
> > >  	if (!ret)
> > >  		ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, mac);
> > >  	return ret;
> > > diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > > index 76de55306c4d..175bf9b13058 100644
> > > --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > > +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
> > > @@ -10215,11 +10215,12 @@ int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size)
> > >   *	t4_set_vf_mac_acl - Set MAC address for the specified VF
> > >   *	@adapter: The adapter
> > >   *	@vf: one of the VFs instantiated by the specified PF
> > > + *	@start: The start port id associated with specified VF
> > >   *	@naddr: the number of MAC addresses
> > >   *	@addr: the MAC address(es) to be set to the specified VF
> > >   */
> > >  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> > > -		      unsigned int naddr, u8 *addr)
> > > +		      u8 start, unsigned int naddr, u8 *addr)
> > >  {
> > >  	struct fw_acl_mac_cmd cmd;
> > >  
> > > @@ -10234,7 +10235,7 @@ int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
> > >  	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
> > >  	cmd.nmac = naddr;
> > >  
> > > -	switch (adapter->pf) {
> > > +	switch (start) {
> > >  	case 3:
> > >  		memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
> > You can use ether_addr_copy().
> > 
> > Beside that and fixes tag:
> > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > 
> > >  		break;
> > > -- 
> > > 2.39.3
> there are multiple instances where memcpy needs to be replaced. I will
> send a separate patch to replace memcpy with ethr_addr_copy().
> 

Great, thanks.

> Thanks
diff mbox series

Patch

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 75bd69ff61a8..c7c2c15a1815 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -2076,7 +2076,7 @@  void t4_idma_monitor(struct adapter *adapter,
 		     struct sge_idma_monitor_state *idma,
 		     int hz, int ticks);
 int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
-		      unsigned int naddr, u8 *addr);
+		      u8 start, unsigned int naddr, u8 *addr);
 void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
 		    u32 start_index, bool sleep_ok);
 void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 97a261d5357e..bc3af0054406 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3234,7 +3234,7 @@  static int cxgb4_mgmt_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
 
 	dev_info(pi->adapter->pdev_dev,
 		 "Setting MAC %pM on VF %d\n", mac, vf);
-	ret = t4_set_vf_mac_acl(adap, vf + 1, 1, mac);
+	ret = t4_set_vf_mac_acl(adap, vf + 1, pi->lport, 1, mac);
 	if (!ret)
 		ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, mac);
 	return ret;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 76de55306c4d..175bf9b13058 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -10215,11 +10215,12 @@  int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size)
  *	t4_set_vf_mac_acl - Set MAC address for the specified VF
  *	@adapter: The adapter
  *	@vf: one of the VFs instantiated by the specified PF
+ *	@start: The start port id associated with specified VF
  *	@naddr: the number of MAC addresses
  *	@addr: the MAC address(es) to be set to the specified VF
  */
 int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
-		      unsigned int naddr, u8 *addr)
+		      u8 start, unsigned int naddr, u8 *addr)
 {
 	struct fw_acl_mac_cmd cmd;
 
@@ -10234,7 +10235,7 @@  int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
 	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
 	cmd.nmac = naddr;
 
-	switch (adapter->pf) {
+	switch (start) {
 	case 3:
 		memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
 		break;