qede: Simplify the usage of qede-flags.
The values represented by qede->flags is being used in mixed ways: 1. As 'value' at some places e.g., QEDE_FLAGS_IS_VF usage 2. As bit-mask(value) at some places e.g., QEDE_FLAGS_PTP_TX_IN_PRORGESS usage. This implementation pose problems in future when we want to add more flag values e.g., overlap of the values, overflow of 64-bit storage. Updated the implementation to go with approach (2) for qede->flags. Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com> Signed-off-by: Ariel Elior <Ariel.Elior@cavium.com> Signed-off-by: Michal Kalderon <Michal.Kalderon@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ec036eb92e
commit
149d3775f1
|
@ -168,6 +168,12 @@ struct qede_ptp;
|
|||
|
||||
#define QEDE_RFS_MAX_FLTR 256
|
||||
|
||||
enum qede_flags_bit {
|
||||
QEDE_FLAGS_IS_VF = 0,
|
||||
QEDE_FLAGS_PTP_TX_IN_PRORGESS,
|
||||
QEDE_FLAGS_TX_TIMESTAMPING_EN
|
||||
};
|
||||
|
||||
struct qede_dev {
|
||||
struct qed_dev *cdev;
|
||||
struct net_device *ndev;
|
||||
|
@ -177,10 +183,7 @@ struct qede_dev {
|
|||
u8 dp_level;
|
||||
|
||||
unsigned long flags;
|
||||
#define QEDE_FLAG_IS_VF BIT(0)
|
||||
#define IS_VF(edev) (!!((edev)->flags & QEDE_FLAG_IS_VF))
|
||||
#define QEDE_TX_TIMESTAMPING_EN BIT(1)
|
||||
#define QEDE_FLAGS_PTP_TX_IN_PRORGESS BIT(2)
|
||||
#define IS_VF(edev) (test_bit(QEDE_FLAGS_IS_VF, &(edev)->flags))
|
||||
|
||||
const struct qed_eth_ops *ops;
|
||||
struct qede_ptp *ptp;
|
||||
|
|
|
@ -1086,7 +1086,7 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level,
|
|||
}
|
||||
|
||||
if (is_vf)
|
||||
edev->flags |= QEDE_FLAG_IS_VF;
|
||||
set_bit(QEDE_FLAGS_IS_VF, &edev->flags);
|
||||
|
||||
qede_init_ndev(edev);
|
||||
|
||||
|
|
|
@ -223,12 +223,12 @@ static int qede_ptp_cfg_filters(struct qede_dev *edev)
|
|||
|
||||
switch (ptp->tx_type) {
|
||||
case HWTSTAMP_TX_ON:
|
||||
edev->flags |= QEDE_TX_TIMESTAMPING_EN;
|
||||
set_bit(QEDE_FLAGS_TX_TIMESTAMPING_EN, &edev->flags);
|
||||
tx_type = QED_PTP_HWTSTAMP_TX_ON;
|
||||
break;
|
||||
|
||||
case HWTSTAMP_TX_OFF:
|
||||
edev->flags &= ~QEDE_TX_TIMESTAMPING_EN;
|
||||
clear_bit(QEDE_FLAGS_TX_TIMESTAMPING_EN, &edev->flags);
|
||||
tx_type = QED_PTP_HWTSTAMP_TX_OFF;
|
||||
break;
|
||||
|
||||
|
@ -518,7 +518,7 @@ void qede_ptp_tx_ts(struct qede_dev *edev, struct sk_buff *skb)
|
|||
if (test_and_set_bit_lock(QEDE_FLAGS_PTP_TX_IN_PRORGESS, &edev->flags))
|
||||
return;
|
||||
|
||||
if (unlikely(!(edev->flags & QEDE_TX_TIMESTAMPING_EN))) {
|
||||
if (unlikely(!test_bit(QEDE_FLAGS_TX_TIMESTAMPING_EN, &edev->flags))) {
|
||||
DP_NOTICE(edev,
|
||||
"Tx timestamping was not enabled, this packet will not be timestamped\n");
|
||||
} else if (unlikely(ptp->tx_skb)) {
|
||||
|
|
Loading…
Reference in New Issue