Skip to content

Commit 289e922

Browse files
committed
dpll: move all dpll<>netdev helpers to dpll code
Older versions of GCC really want to know the full definition of the type involved in rcu_assign_pointer(). struct dpll_pin is defined in a local header, net/core can't reach it. Move all the netdev <> dpll code into dpll, where the type is known. Otherwise we'd need multiple function calls to jump between the compilation units. This is the same problem the commit under fixes was trying to address, but with rcu_assign_pointer() not rcu_dereference(). Some of the exports are not needed, networking core can't be a module, we only need exports for the helpers used by drivers. Reported-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Fixes: 640f41e ("dpll: fix build failure due to rcu_dereference_check() on unknown type") Reviewed-by: Jiri Pirko <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 685f7d5 commit 289e922

File tree

9 files changed

+64
-65
lines changed

9 files changed

+64
-65
lines changed

Documentation/driver-api/dpll.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ In such scenario, dpll device input signal shall be also configurable
545545
to drive dpll with signal recovered from the PHY netdevice.
546546
This is done by exposing a pin to the netdevice - attaching pin to the
547547
netdevice itself with
548-
``netdev_dpll_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin)``.
548+
``dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin)``.
549549
Exposed pin id handle ``DPLL_A_PIN_ID`` is then identifiable by the user
550550
as it is attached to rtnetlink respond to get ``RTM_NEWLINK`` command in
551551
nested attribute ``IFLA_DPLL_PIN``.

drivers/dpll/dpll_core.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ struct dpll_pin_registration {
4242
void *priv;
4343
};
4444

45-
struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
46-
{
47-
return rcu_dereference_rtnl(dev->dpll_pin);
48-
}
49-
5045
struct dpll_device *dpll_device_get_by_id(int id)
5146
{
5247
if (xa_get_mark(&dpll_device_xa, id, DPLL_REGISTERED))
@@ -513,6 +508,26 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
513508
return ERR_PTR(ret);
514509
}
515510

511+
static void dpll_netdev_pin_assign(struct net_device *dev, struct dpll_pin *dpll_pin)
512+
{
513+
rtnl_lock();
514+
rcu_assign_pointer(dev->dpll_pin, dpll_pin);
515+
rtnl_unlock();
516+
}
517+
518+
void dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin)
519+
{
520+
WARN_ON(!dpll_pin);
521+
dpll_netdev_pin_assign(dev, dpll_pin);
522+
}
523+
EXPORT_SYMBOL(dpll_netdev_pin_set);
524+
525+
void dpll_netdev_pin_clear(struct net_device *dev)
526+
{
527+
dpll_netdev_pin_assign(dev, NULL);
528+
}
529+
EXPORT_SYMBOL(dpll_netdev_pin_clear);
530+
516531
/**
517532
* dpll_pin_get - find existing or create new dpll pin
518533
* @clock_id: clock_id of creator

drivers/dpll/dpll_netlink.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
#include <linux/module.h>
1010
#include <linux/kernel.h>
11+
#include <linux/netdevice.h>
1112
#include <net/genetlink.h>
1213
#include "dpll_core.h"
1314
#include "dpll_netlink.h"
@@ -47,18 +48,6 @@ dpll_msg_add_dev_parent_handle(struct sk_buff *msg, u32 id)
4748
return 0;
4849
}
4950

50-
/**
51-
* dpll_msg_pin_handle_size - get size of pin handle attribute for given pin
52-
* @pin: pin pointer
53-
*
54-
* Return: byte size of pin handle attribute for given pin.
55-
*/
56-
size_t dpll_msg_pin_handle_size(struct dpll_pin *pin)
57-
{
58-
return pin ? nla_total_size(4) : 0; /* DPLL_A_PIN_ID */
59-
}
60-
EXPORT_SYMBOL_GPL(dpll_msg_pin_handle_size);
61-
6251
/**
6352
* dpll_msg_add_pin_handle - attach pin handle attribute to a given message
6453
* @msg: pointer to sk_buff message to attach a pin handle
@@ -68,15 +57,36 @@ EXPORT_SYMBOL_GPL(dpll_msg_pin_handle_size);
6857
* * 0 - success
6958
* * -EMSGSIZE - no space in message to attach pin handle
7059
*/
71-
int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin)
60+
static int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin)
7261
{
7362
if (!pin)
7463
return 0;
7564
if (nla_put_u32(msg, DPLL_A_PIN_ID, pin->id))
7665
return -EMSGSIZE;
7766
return 0;
7867
}
79-
EXPORT_SYMBOL_GPL(dpll_msg_add_pin_handle);
68+
69+
static struct dpll_pin *dpll_netdev_pin(const struct net_device *dev)
70+
{
71+
return rcu_dereference_rtnl(dev->dpll_pin);
72+
}
73+
74+
/**
75+
* dpll_netdev_pin_handle_size - get size of pin handle attribute of a netdev
76+
* @dev: netdev from which to get the pin
77+
*
78+
* Return: byte size of pin handle attribute, or 0 if @dev has no pin.
79+
*/
80+
size_t dpll_netdev_pin_handle_size(const struct net_device *dev)
81+
{
82+
return dpll_netdev_pin(dev) ? nla_total_size(4) : 0; /* DPLL_A_PIN_ID */
83+
}
84+
85+
int dpll_netdev_add_pin_handle(struct sk_buff *msg,
86+
const struct net_device *dev)
87+
{
88+
return dpll_msg_add_pin_handle(msg, dpll_netdev_pin(dev));
89+
}
8090

8191
static int
8292
dpll_msg_add_mode(struct sk_buff *msg, struct dpll_device *dpll,

drivers/net/ethernet/intel/ice/ice_dpll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ static void ice_dpll_deinit_rclk_pin(struct ice_pf *pf)
15971597
}
15981598
if (WARN_ON_ONCE(!vsi || !vsi->netdev))
15991599
return;
1600-
netdev_dpll_pin_clear(vsi->netdev);
1600+
dpll_netdev_pin_clear(vsi->netdev);
16011601
dpll_pin_put(rclk->pin);
16021602
}
16031603

@@ -1641,7 +1641,7 @@ ice_dpll_init_rclk_pins(struct ice_pf *pf, struct ice_dpll_pin *pin,
16411641
}
16421642
if (WARN_ON((!vsi || !vsi->netdev)))
16431643
return -EINVAL;
1644-
netdev_dpll_pin_set(vsi->netdev, pf->dplls.rclk.pin);
1644+
dpll_netdev_pin_set(vsi->netdev, pf->dplls.rclk.pin);
16451645

16461646
return 0;
16471647

drivers/net/ethernet/mellanox/mlx5/core/dpll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ static void mlx5_dpll_netdev_dpll_pin_set(struct mlx5_dpll *mdpll,
261261
{
262262
if (mdpll->tracking_netdev)
263263
return;
264-
netdev_dpll_pin_set(netdev, mdpll->dpll_pin);
264+
dpll_netdev_pin_set(netdev, mdpll->dpll_pin);
265265
mdpll->tracking_netdev = netdev;
266266
}
267267

268268
static void mlx5_dpll_netdev_dpll_pin_clear(struct mlx5_dpll *mdpll)
269269
{
270270
if (!mdpll->tracking_netdev)
271271
return;
272-
netdev_dpll_pin_clear(mdpll->tracking_netdev);
272+
dpll_netdev_pin_clear(mdpll->tracking_netdev);
273273
mdpll->tracking_netdev = NULL;
274274
}
275275

include/linux/dpll.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,24 @@ struct dpll_pin_properties {
122122
};
123123

124124
#if IS_ENABLED(CONFIG_DPLL)
125-
size_t dpll_msg_pin_handle_size(struct dpll_pin *pin);
126-
int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin);
125+
void dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin);
126+
void dpll_netdev_pin_clear(struct net_device *dev);
127+
128+
size_t dpll_netdev_pin_handle_size(const struct net_device *dev);
129+
int dpll_netdev_add_pin_handle(struct sk_buff *msg,
130+
const struct net_device *dev);
127131
#else
128-
static inline size_t dpll_msg_pin_handle_size(struct dpll_pin *pin)
132+
static inline void
133+
dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin) { }
134+
static inline void dpll_netdev_pin_clear(struct net_device *dev) { }
135+
136+
static inline size_t dpll_netdev_pin_handle_size(const struct net_device *dev)
129137
{
130138
return 0;
131139
}
132140

133-
static inline int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin)
141+
static inline int
142+
dpll_netdev_add_pin_handle(struct sk_buff *msg, const struct net_device *dev)
134143
{
135144
return 0;
136145
}
@@ -169,13 +178,4 @@ int dpll_device_change_ntf(struct dpll_device *dpll);
169178

170179
int dpll_pin_change_ntf(struct dpll_pin *pin);
171180

172-
#if !IS_ENABLED(CONFIG_DPLL)
173-
static inline struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
174-
{
175-
return NULL;
176-
}
177-
#else
178-
struct dpll_pin *netdev_dpll_pin(const struct net_device *dev);
179-
#endif
180-
181181
#endif

include/linux/netdevice.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ struct xdp_buff;
7979
struct xdp_frame;
8080
struct xdp_metadata_ops;
8181
struct xdp_md;
82-
/* DPLL specific */
83-
struct dpll_pin;
8482

8583
typedef u32 xdp_features_t;
8684

@@ -4042,8 +4040,6 @@ int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name);
40424040
int dev_get_port_parent_id(struct net_device *dev,
40434041
struct netdev_phys_item_id *ppid, bool recurse);
40444042
bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
4045-
void netdev_dpll_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin);
4046-
void netdev_dpll_pin_clear(struct net_device *dev);
40474043

40484044
struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again);
40494045
struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,

net/core/dev.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9074,28 +9074,6 @@ bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b)
90749074
}
90759075
EXPORT_SYMBOL(netdev_port_same_parent_id);
90769076

9077-
static void netdev_dpll_pin_assign(struct net_device *dev, struct dpll_pin *dpll_pin)
9078-
{
9079-
#if IS_ENABLED(CONFIG_DPLL)
9080-
rtnl_lock();
9081-
rcu_assign_pointer(dev->dpll_pin, dpll_pin);
9082-
rtnl_unlock();
9083-
#endif
9084-
}
9085-
9086-
void netdev_dpll_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin)
9087-
{
9088-
WARN_ON(!dpll_pin);
9089-
netdev_dpll_pin_assign(dev, dpll_pin);
9090-
}
9091-
EXPORT_SYMBOL(netdev_dpll_pin_set);
9092-
9093-
void netdev_dpll_pin_clear(struct net_device *dev)
9094-
{
9095-
netdev_dpll_pin_assign(dev, NULL);
9096-
}
9097-
EXPORT_SYMBOL(netdev_dpll_pin_clear);
9098-
90999077
/**
91009078
* dev_change_proto_down - set carrier according to proto_down.
91019079
*

net/core/rtnetlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static size_t rtnl_dpll_pin_size(const struct net_device *dev)
10571057
{
10581058
size_t size = nla_total_size(0); /* nest IFLA_DPLL_PIN */
10591059

1060-
size += dpll_msg_pin_handle_size(netdev_dpll_pin(dev));
1060+
size += dpll_netdev_pin_handle_size(dev);
10611061

10621062
return size;
10631063
}
@@ -1792,7 +1792,7 @@ static int rtnl_fill_dpll_pin(struct sk_buff *skb,
17921792
if (!dpll_pin_nest)
17931793
return -EMSGSIZE;
17941794

1795-
ret = dpll_msg_add_pin_handle(skb, netdev_dpll_pin(dev));
1795+
ret = dpll_netdev_add_pin_handle(skb, dev);
17961796
if (ret < 0)
17971797
goto nest_cancel;
17981798

0 commit comments

Comments
 (0)