Skip to content

Commit 6ee1652

Browse files
yizoudavem330
authored andcommitted
ixgbe: Add support for dcbnl_rtnl_ops.setapp/getapp
Add support for dcbnl_rtnl_ops.setapp/getapp to set or get the current user priority bitmap for the given application protocol. Currently, 82599 only supports setapp/getapp for Fiber Channel over Ethernet (FCoE) protocol. Signed-off-by: Yi Zou <[email protected]> Acked-by: Peter P Waskiewicz Jr <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5794968 commit 6ee1652

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

drivers/net/ixgbe/ixgbe.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
452452
extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
453453
extern int ixgbe_fcoe_enable(struct net_device *netdev);
454454
extern int ixgbe_fcoe_disable(struct net_device *netdev);
455+
#ifdef CONFIG_IXGBE_DCB
456+
extern u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter);
457+
extern u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);
458+
#endif /* CONFIG_IXGBE_DCB */
455459
#endif /* IXGBE_FCOE */
456460

457461
#endif /* _IXGBE_H_ */

drivers/net/ixgbe/ixgbe_dcb_nl.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,64 @@ static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
480480
return;
481481
}
482482

483+
/**
484+
* ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
485+
* @netdev : the corresponding netdev
486+
* @idtype : identifies the id as ether type or TCP/UDP port number
487+
* @id: id is either ether type or TCP/UDP port number
488+
*
489+
* Returns : on success, returns a non-zero 802.1p user priority bitmap
490+
* otherwise returns 0 as the invalid user priority bitmap to indicate an
491+
* error.
492+
*/
493+
static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
494+
{
495+
u8 rval = 0;
496+
497+
switch (idtype) {
498+
case DCB_APP_IDTYPE_ETHTYPE:
499+
#ifdef IXGBE_FCOE
500+
if (id == ETH_P_FCOE)
501+
rval = ixgbe_fcoe_getapp(netdev_priv(netdev));
502+
#endif
503+
break;
504+
case DCB_APP_IDTYPE_PORTNUM:
505+
break;
506+
default:
507+
break;
508+
}
509+
return rval;
510+
}
511+
512+
/**
513+
* ixgbe_dcbnl_setapp - set the DCBX application user priority
514+
* @netdev : the corresponding netdev
515+
* @idtype : identifies the id as ether type or TCP/UDP port number
516+
* @id: id is either ether type or TCP/UDP port number
517+
* @up: the 802.1p user priority bitmap
518+
*
519+
* Returns : 0 on success or 1 on error
520+
*/
521+
static u8 ixgbe_dcbnl_setapp(struct net_device *netdev,
522+
u8 idtype, u16 id, u8 up)
523+
{
524+
u8 rval = 1;
525+
526+
switch (idtype) {
527+
case DCB_APP_IDTYPE_ETHTYPE:
528+
#ifdef IXGBE_FCOE
529+
if (id == ETH_P_FCOE)
530+
rval = ixgbe_fcoe_setapp(netdev_priv(netdev), up);
531+
#endif
532+
break;
533+
case DCB_APP_IDTYPE_PORTNUM:
534+
break;
535+
default:
536+
break;
537+
}
538+
return rval;
539+
}
540+
483541
struct dcbnl_rtnl_ops dcbnl_ops = {
484542
.getstate = ixgbe_dcbnl_get_state,
485543
.setstate = ixgbe_dcbnl_set_state,
@@ -500,5 +558,7 @@ struct dcbnl_rtnl_ops dcbnl_ops = {
500558
.setnumtcs = ixgbe_dcbnl_setnumtcs,
501559
.getpfcstate = ixgbe_dcbnl_getpfcstate,
502560
.setpfcstate = ixgbe_dcbnl_setpfcstate,
561+
.getapp = ixgbe_dcbnl_getapp,
562+
.setapp = ixgbe_dcbnl_setapp,
503563
};
504564

drivers/net/ixgbe/ixgbe_fcoe.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828

2929
#include "ixgbe.h"
30+
#ifdef CONFIG_IXGBE_DCB
31+
#include "ixgbe_dcb_82599.h"
32+
#endif /* CONFIG_IXGBE_DCB */
3033
#include <linux/if_ether.h>
3134
#include <scsi/scsi_cmnd.h>
3235
#include <scsi/scsi_device.h>
@@ -648,3 +651,64 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
648651
out_disable:
649652
return rc;
650653
}
654+
655+
#ifdef CONFIG_IXGBE_DCB
656+
/**
657+
* ixgbe_fcoe_getapp - retrieves current user priority bitmap for FCoE
658+
* @adapter : ixgbe adapter
659+
*
660+
* Finds out the corresponding user priority bitmap from the current
661+
* traffic class that FCoE belongs to. Returns 0 as the invalid user
662+
* priority bitmap to indicate an error.
663+
*
664+
* Returns : 802.1p user priority bitmap for FCoE
665+
*/
666+
u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter)
667+
{
668+
int i;
669+
u8 tc;
670+
u32 up2tc;
671+
672+
up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC);
673+
for (i = 0; i < MAX_USER_PRIORITY; i++) {
674+
tc = (u8)(up2tc >> (i * IXGBE_RTTUP2TC_UP_SHIFT));
675+
tc &= (MAX_TRAFFIC_CLASS - 1);
676+
if (adapter->fcoe.tc == tc)
677+
return 1 << i;
678+
}
679+
680+
return 0;
681+
}
682+
683+
/**
684+
* ixgbe_fcoe_setapp - sets the user priority bitmap for FCoE
685+
* @adapter : ixgbe adapter
686+
* @up : 802.1p user priority bitmap
687+
*
688+
* Finds out the traffic class from the input user priority
689+
* bitmap for FCoE.
690+
*
691+
* Returns : 0 on success otherwise returns 1 on error
692+
*/
693+
u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up)
694+
{
695+
int i;
696+
u32 up2tc;
697+
698+
/* valid user priority bitmap must not be 0 */
699+
if (up) {
700+
/* from user priority to the corresponding traffic class */
701+
up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC);
702+
for (i = 0; i < MAX_USER_PRIORITY; i++) {
703+
if (up & (1 << i)) {
704+
up2tc >>= (i * IXGBE_RTTUP2TC_UP_SHIFT);
705+
up2tc &= (MAX_TRAFFIC_CLASS - 1);
706+
adapter->fcoe.tc = (u8)up2tc;
707+
return 0;
708+
}
709+
}
710+
}
711+
712+
return 1;
713+
}
714+
#endif /* CONFIG_IXGBE_DCB */

drivers/net/ixgbe/ixgbe_fcoe.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#define IXGBE_FCBUFF_MIN 4096 /* 4KB min */
4747
#define IXGBE_FCOE_DDP_MAX 512 /* 9 bits xid */
4848

49+
/* Default traffic class to use for FCoE */
50+
#define IXGBE_FCOE_DEFTC 3
51+
4952
/* fcerr */
5053
#define IXGBE_FCERR_BADCRC 0x00100000
5154

@@ -59,6 +62,7 @@ struct ixgbe_fcoe_ddp {
5962
};
6063

6164
struct ixgbe_fcoe {
65+
u8 tc;
6266
spinlock_t lock;
6367
struct pci_pool *pool;
6468
struct ixgbe_fcoe_ddp ddp[IXGBE_FCOE_DDP_MAX];

drivers/net/ixgbe/ixgbe_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,6 +3801,8 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
38013801
adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE;
38023802
adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
38033803
adapter->ring_feature[RING_F_FCOE].indices = 0;
3804+
/* Default traffic class to use for FCoE */
3805+
adapter->fcoe.tc = IXGBE_FCOE_DEFTC;
38043806
#endif /* IXGBE_FCOE */
38053807
}
38063808

0 commit comments

Comments
 (0)