Skip to contentSkip to conversation

qed: Remove unneeded enumerated type core_tx_dest

PATCH In review Nathan Chancellor 3 participants 6 messages Oct 4, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qed: Remove unneeded enumerated type core_tx_dest

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

These enumerated types are not 1 to 1:

/* Light L2 TX Destination */
enum core_tx_dest {
CORE_TX_DEST_NW,
CORE_TX_DEST_LB,
CORE_TX_DEST_RESERVED,
CORE_TX_DEST_DROP,
MAX_CORE_TX_DEST
};

enum qed_ll2_tx_dest {
QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */ QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */ QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */ QED_LL2_TX_DEST_MAX
};

Fix this conversion warning by adding CORE_TX_DEST_DROP to qed_ll2_tx_dest and converting all values of core_tx_dest to the equivalent value in qed_ll2_tx_dest so that there is no conversion warning or functional change.

---

I'm by no means married to the name of the new enum value, it could even be CORE_TX_DEST_DROP (didn't know if that was going to set anyone off or not) but this is the cleanest solution to the warning in my opinion but I'm open to other opinions.

 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  9 ---------
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 16 ++++++++--------
 drivers/net/ethernet/qlogic/qed/qed_ll2.h |  2 +-
 include/linux/qed/qed_ll2_if.h            |  1 +
 4 files changed, 10 insertions(+), 18 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_hsi.h +0 -9
index 15b4cd317f14..c2ce8428c413 100644
@@ -331,15 +331,6 @@ struct core_tx_bd {
 #define CORE_TX_BD_TX_DST_SHIFT			14
 };
 
-/* Light L2 TX Destination */
-enum core_tx_dest {
-	CORE_TX_DEST_NW,
-	CORE_TX_DEST_LB,
-	CORE_TX_DEST_RESERVED,
-	CORE_TX_DEST_DROP,
-	MAX_CORE_TX_DEST
-};
-
 /* Ramrod data for tx queue start ramrod */
 struct core_tx_start_ramrod_data {
 	struct regpair pbl_base_addr;
drivers/net/ethernet/qlogic/qed/qed_ll2.c +8 -8
index da13117a604a..741185a62e84 100644
@@ -1345,13 +1345,13 @@ int qed_ll2_acquire_connection(void *cxt, struct qed_ll2_acquire_data *data)
 
 	switch (data->input.tx_dest) {
 	case QED_LL2_TX_DEST_NW:
-		p_ll2_info->tx_dest = CORE_TX_DEST_NW;
+		p_ll2_info->tx_dest = QED_LL2_TX_DEST_NW;
 		break;
 	case QED_LL2_TX_DEST_LB:
-		p_ll2_info->tx_dest = CORE_TX_DEST_LB;
+		p_ll2_info->tx_dest = QED_LL2_TX_DEST_LB;
 		break;
 	case QED_LL2_TX_DEST_DROP:
-		p_ll2_info->tx_dest = CORE_TX_DEST_DROP;
+		p_ll2_info->tx_dest = QED_LL2_TX_DEST_DROP_CORE;
 		break;
 	default:
 		return -EINVAL;
@@ -1684,7 +1684,7 @@ qed_ll2_prepare_tx_packet_set_bd(struct qed_hwfn *p_hwfn,
 	u16 prod_idx = qed_chain_get_prod_idx(p_tx_chain);
 	struct core_tx_bd *start_bd = NULL;
 	enum core_roce_flavor_type roce_flavor;
-	enum core_tx_dest tx_dest;
+	enum qed_ll2_tx_dest tx_dest;
 	u16 bd_data = 0, frag_idx;
 
 	roce_flavor = (pkt->qed_roce_flavor == QED_LL2_ROCE) ? CORE_ROCE
@@ -1692,16 +1692,16 @@ qed_ll2_prepare_tx_packet_set_bd(struct qed_hwfn *p_hwfn,
 
 	switch (pkt->tx_dest) {
 	case QED_LL2_TX_DEST_NW:
-		tx_dest = CORE_TX_DEST_NW;
+		tx_dest = QED_LL2_TX_DEST_NW;
 		break;
 	case QED_LL2_TX_DEST_LB:
-		tx_dest = CORE_TX_DEST_LB;
+		tx_dest = QED_LL2_TX_DEST_LB;
 		break;
 	case QED_LL2_TX_DEST_DROP:
-		tx_dest = CORE_TX_DEST_DROP;
+		tx_dest = QED_LL2_TX_DEST_DROP_CORE;
 		break;
 	default:
-		tx_dest = CORE_TX_DEST_LB;
+		tx_dest = QED_LL2_TX_DEST_LB;
 		break;
 	}
 
drivers/net/ethernet/qlogic/qed/qed_ll2.h +1 -1
index 1a5c1ae01474..e676bbaf55c9 100644
@@ -119,7 +119,7 @@ struct qed_ll2_info {
 	u8 queue_id;
 	u8 tx_stats_id;
 	bool b_active;
-	enum core_tx_dest tx_dest;
+	enum qed_ll2_tx_dest tx_dest;
 	u8 tx_stats_en;
 	bool main_func_queue;
 	struct qed_ll2_rx_queue rx_queue;
include/linux/qed/qed_ll2_if.h +1 -0
index 5eb022953aca..1b260e73943c 100644
@@ -65,6 +65,7 @@ enum qed_ll2_tx_dest {
 	QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */
 	QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */
 	QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */
+	QED_LL2_TX_DEST_DROP_CORE, /* CORE_TX_DEST_DROP value */
 	QED_LL2_TX_DEST_MAX
 };
 
Signature · 1 line
2.19.0
#1 lore raw

From: Nathan Chancellor <[email protected]>
Sent: Thursday, October 04, 2018 3:09 AM

Quoted 34 lines

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

These enumerated types are not 1 to 1:

/* Light L2 TX Destination */
enum core_tx_dest {
CORE_TX_DEST_NW,
CORE_TX_DEST_LB,
CORE_TX_DEST_RESERVED,
CORE_TX_DEST_DROP,
MAX_CORE_TX_DEST
};

enum qed_ll2_tx_dest {
QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */ QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */ QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */ QED_LL2_TX_DEST_MAX
};

Fix this conversion warning by adding CORE_TX_DEST_DROP to qed_ll2_tx_dest and converting all values of core_tx_dest to the equivalent value in qed_ll2_tx_dest so that there is no conversion warning or functional change.

[...]

Quoted 8 lines
drivers/net/ethernet/qlogic/qed/qed_hsi.h +0 -8
-/* Light L2 TX Destination */
-enum core_tx_dest {
-       CORE_TX_DEST_NW,
-       CORE_TX_DEST_LB,
-       CORE_TX_DEST_RESERVED,
-       CORE_TX_DEST_DROP,
-       MAX_CORE_TX_DEST
-};

[...]

Quoted 6 lines

QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */ QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */ QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */
+ QED_LL2_TX_DEST_DROP_CORE, /* CORE_TX_DEST_DROP value */

        QED_LL2_TX_DEST_MAX

};

Thanks Nathan for finding this issue.
"enum core_tx_dest" is for the interface with the device FW, while "enum qed_ll2_tx_dest" is for the interface with other qed* kernel modules. The distinction is on purpose, so "enum core_tx_dest" shouldn't be deleted.
Maybe an explicit switch/case would be better as a fix?
E.g. -
- tx_pkt.tx_dest = p_ll2_conn->tx_dest;
+ switch (p_ll2_conn->tx_dest) {
+ case CORE_TX_DEST_NW:
+ tx_pkt.tx_dest = QED_LL2_TX_DEST_NW;
+ break;
+ case CORE_TX_DEST_LB:
+ tx_pkt.tx_dest = QED_LL2_TX_DEST_LB;
+ break;
+ case CORE_TX_DEST_DROP:
+ tx_pkt.tx_dest = QED_LL2_TX_DEST_DROP;
+ break;
+ default:
+ tx_pkt.tx_dest = QED_LL2_TX_DEST_DROP;
+ }

#2 lore raw
Quoted 68 lines · Tomer

From: Nathan Chancellor <[email protected]>
Sent: Thursday, October 04, 2018 3:09 AM

Quoted 34 lines

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

These enumerated types are not 1 to 1:

/* Light L2 TX Destination */
enum core_tx_dest {
CORE_TX_DEST_NW,
CORE_TX_DEST_LB,
CORE_TX_DEST_RESERVED,
CORE_TX_DEST_DROP,
MAX_CORE_TX_DEST
};

enum qed_ll2_tx_dest {
QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */ QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */ QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */ QED_LL2_TX_DEST_MAX
};

Fix this conversion warning by adding CORE_TX_DEST_DROP to qed_ll2_tx_dest and converting all values of core_tx_dest to the equivalent value in qed_ll2_tx_dest so that there is no conversion warning or functional change.

[...]

Quoted 8 lines
drivers/net/ethernet/qlogic/qed/qed_hsi.h +0 -8
-/* Light L2 TX Destination */
-enum core_tx_dest {
-       CORE_TX_DEST_NW,
-       CORE_TX_DEST_LB,
-       CORE_TX_DEST_RESERVED,
-       CORE_TX_DEST_DROP,
-       MAX_CORE_TX_DEST
-};

[...]

Quoted 6 lines

QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */ QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */ QED_LL2_TX_DEST_DROP, /* Light L2 Drop the TX packet */
+ QED_LL2_TX_DEST_DROP_CORE, /* CORE_TX_DEST_DROP value */

        QED_LL2_TX_DEST_MAX

};

Thanks Nathan for finding this issue.
"enum core_tx_dest" is for the interface with the device FW, while "enum qed_ll2_tx_dest" is for the interface with other qed* kernel modules. The distinction is on purpose, so "enum core_tx_dest" shouldn't be deleted.
Maybe an explicit switch/case would be better as a fix?
E.g. -

(quoted diff) +3 -1
-		tx_pkt.tx_dest = p_ll2_conn->tx_dest;
+		switch (p_ll2_conn->tx_dest) {
+		case CORE_TX_DEST_NW:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_NW;

Review

Quoted 10 lines
(quoted diff) +10 -0
+			break;
+		case CORE_TX_DEST_LB:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_LB;
+			break;
+		case CORE_TX_DEST_DROP:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_DROP;
+			break;
+		default:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_DROP;
+		}

Hi Tomer,

Yes, that should work and it would match the rest of the driver's handling of this distinction. I will go ahead and spin up a v2 here shortly for review, thank you.

Nathan

#3 lore raw

PATCH v2 1/1 qed: Avoid implicit enum conversion in qed_ooo_submit_tx_buffers

In reply to Nathan Chancellor

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

Fix this by using a switch statement to convert between the enumerated values since they are not 1 to 1, which matches how the rest of the driver handles this conversion.

---

v1 -> v2:

* Use an explicit switch statement to convert between the enumerated types like the rest of the driver, as suggested by Tomer.

 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_ll2.c +12 -1
index da13117a604a..aa633381aa47 100644
@@ -796,7 +796,18 @@ qed_ooo_submit_tx_buffers(struct qed_hwfn *p_hwfn,
 		tx_pkt.vlan = p_buffer->vlan;
 		tx_pkt.bd_flags = bd_flags;
 		tx_pkt.l4_hdr_offset_w = l4_hdr_offset_w;
-		tx_pkt.tx_dest = p_ll2_conn->tx_dest;
+		switch (p_ll2_conn->tx_dest) {
+		case CORE_TX_DEST_NW:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_NW;
+			break;
+		case CORE_TX_DEST_LB:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_LB;
+			break;
+		case CORE_TX_DEST_DROP:
+		default:
+			tx_pkt.tx_dest = QED_LL2_TX_DEST_DROP;
+			break;
+		}
 		tx_pkt.first_frag = first_frag;
 		tx_pkt.first_frag_len = p_buffer->packet_length;
 		tx_pkt.cookie = p_buffer;
Signature · 1 line
2.19.0
Acked-by on v2 1/1
#4 lore raw

RE: [PATCH v2] qed: Avoid implicit enum conversion in qed_ooo_submit_tx_buffers

From: Nathan Chancellor <[email protected]>
Sent: Thursday, October 04, 2018 7:39 PM

Quoted 16 lines

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

Fix this by using a switch statement to convert between the enumerated values since they are not 1 to 1, which matches how the rest of the driver handles this conversion.

Quoted 6 lines

---

v1 -> v2:

* Use an explicit switch statement to convert between the enumerated types like the rest of the driver, as suggested by Tomer.

Thanks

maintainer Applied
#5 lore raw

Re: [PATCH v2] qed: Avoid implicit enum conversion in qed_ooo_submit_tx_buffers

In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>
Date: Thu, 4 Oct 2018 09:39:20 -0700

Quoted 16 lines

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_ll2.c:799:32: warning: implicit conversion from enumeration type 'enum core_tx_dest' to different enumeration type 'enum qed_ll2_tx_dest' [-Wenum-conversion]

                tx_pkt.tx_dest = p_ll2_conn->tx_dest;
                               ~ ~~~~~~~~~~~~^~~~~~~

1 warning generated.

Fix this by using a switch statement to convert between the enumerated values since they are not 1 to 1, which matches how the rest of the driver handles this conversion.

Quoted 6 lines

---

v1 -> v2:

* Use an explicit switch statement to convert between the enumerated types like the rest of the driver, as suggested by Tomer.

Applied to net-next.