Re: [PATCH net 2/2] net: ethernet: mediatek: fix inconsistency of port number carried in TXD
From: David Miller
Date: Tue Apr 11 2017 - 10:36:00 EST
From: <sean.wang@xxxxxxxxxxxx>
Date: Tue, 11 Apr 2017 15:12:34 +0800
> @@ -410,12 +410,18 @@ struct mtk_hw_stats {
> struct u64_stats_sync syncp;
> };
>
> -/* PDMA descriptor can point at 1-2 segments. This enum allows us to track how
> - * memory was allocated so that it can be freed properly
> - */
> enum mtk_tx_flags {
> + /* PDMA descriptor can point at 1-2 segments. This enum allows us to
> + * track how memory was allocated so that it can be freed properly.
> + */
> MTK_TX_FLAGS_SINGLE0 = 0x01,
> MTK_TX_FLAGS_PAGE0 = 0x02,
> +
> + /* MTK_TX_FLAGS_FPORTx allows tracking which port the transmitted
> + * SKB out instead of looking up through hardware TX descriptor.
> + */
> + MTK_TX_FLAGS_FPORT1 = 0x03,
> + MTK_TX_FLAGS_FPORT0 = 0x04,
> };
You're creating a confusing situation here and asking for bugs to be introduced
into the driver.
The existing two enumeration values are "bit masks", but these two new values
are bit numbers and must be used with BIT().
Make them consistent, and I would suggest to make all of them bit masks, thus:
MTK_TX_FLAGS_FPORT1 = 0x04,
MTK_TX_FLAGS_FPORT0 = 0x08,
And then remove the use of BIT() to these values.
Thanks.