mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 09:09:55 -04:00
netdevice: convert private flags > BIT(31) to bitfields
Make dev->priv_flags `u32` back and define bits higher than 31 as bitfield booleans as per Jakub's suggestion. This simplifies code which accesses these bits with no optimization loss (testb both before/after), allows to not extend &netdev_priv_flags each time, but also scales better as bits > 63 in the future would only add a new u64 to the structure with no complications, comparing to that extending ::priv_flags would require converting it to a bitmap. Note that I picked `unsigned long :1` to not lose any potential optimizations comparing to `bool :1` etc. Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
075e3d30e4
commit
beb5a9bea8
@@ -238,9 +238,9 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
|
||||
|
||||
stats = dev_get_stats(vlandev, &temp);
|
||||
seq_printf(seq,
|
||||
"%s VID: %d REORDER_HDR: %i dev->priv_flags: %llx\n",
|
||||
"%s VID: %d REORDER_HDR: %i dev->priv_flags: %x\n",
|
||||
vlandev->name, vlan->vlan_id,
|
||||
(int)(vlan->flags & 1), vlandev->priv_flags);
|
||||
(int)(vlan->flags & 1), (u32)vlandev->priv_flags);
|
||||
|
||||
seq_printf(seq, fmt64, "total frames received", stats->rx_packets);
|
||||
seq_printf(seq, fmt64, "total bytes received", stats->rx_bytes);
|
||||
|
||||
@@ -9274,7 +9274,7 @@ EXPORT_SYMBOL(netdev_port_same_parent_id);
|
||||
*/
|
||||
int dev_change_proto_down(struct net_device *dev, bool proto_down)
|
||||
{
|
||||
if (!(dev->priv_flags & IFF_CHANGE_PROTO_DOWN))
|
||||
if (!dev->change_proto_down)
|
||||
return -EOPNOTSUPP;
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
@@ -11930,7 +11930,7 @@ static struct pernet_operations __net_initdata default_device_ops = {
|
||||
static void __init net_dev_struct_check(void)
|
||||
{
|
||||
/* TX read-mostly hotpath */
|
||||
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, priv_flags);
|
||||
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, priv_flags_fast);
|
||||
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, netdev_ops);
|
||||
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, header_ops);
|
||||
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, _tx);
|
||||
|
||||
@@ -317,8 +317,7 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
||||
* should take precedence in front of hardware timestamping provided by the
|
||||
* netdev. If the netdev driver needs to perform specific actions even for PHY
|
||||
* timestamping to work properly (a switch port must trap the timestamped
|
||||
* frames and not forward them), it must set IFF_SEE_ALL_HWTSTAMP_REQUESTS in
|
||||
* dev->priv_flags.
|
||||
* frames and not forward them), it must set dev->see_all_hwtstamp_requests.
|
||||
*/
|
||||
int dev_set_hwtstamp_phylib(struct net_device *dev,
|
||||
struct kernel_hwtstamp_config *cfg,
|
||||
@@ -332,13 +331,13 @@ int dev_set_hwtstamp_phylib(struct net_device *dev,
|
||||
|
||||
cfg->source = phy_ts ? HWTSTAMP_SOURCE_PHYLIB : HWTSTAMP_SOURCE_NETDEV;
|
||||
|
||||
if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) {
|
||||
if (phy_ts && dev->see_all_hwtstamp_requests) {
|
||||
err = ops->ndo_hwtstamp_get(dev, &old_cfg);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!phy_ts || (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) {
|
||||
if (!phy_ts || dev->see_all_hwtstamp_requests) {
|
||||
err = ops->ndo_hwtstamp_set(dev, cfg, extack);
|
||||
if (err) {
|
||||
if (extack->_msg)
|
||||
@@ -347,7 +346,7 @@ int dev_set_hwtstamp_phylib(struct net_device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS))
|
||||
if (phy_ts && dev->see_all_hwtstamp_requests)
|
||||
changed = kernel_hwtstamp_config_changed(&old_cfg, cfg);
|
||||
|
||||
if (phy_ts) {
|
||||
|
||||
@@ -2724,7 +2724,7 @@ static int do_set_proto_down(struct net_device *dev,
|
||||
bool proto_down;
|
||||
int err;
|
||||
|
||||
if (!(dev->priv_flags & IFF_CHANGE_PROTO_DOWN)) {
|
||||
if (!dev->change_proto_down) {
|
||||
NL_SET_ERR_MSG(extack, "Protodown not supported by device");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user