mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
net: dsa: introduce a dsa_port_from_netdev public helper
As its implementation shows, this is synonimous with calling dsa_slave_dev_check followed by dsa_slave_to_port, so it is quite simple already and provides functionality which is already there. However there is now a need for these functions outside dsa_priv.h, for example in drivers that perform mirroring and redirection through tc-flower offloads (they are given raw access to the flow_cls_offload structure), where they need to call this function on act->dev. But simply exporting dsa_slave_to_port would make it non-inline and would result in an extra function call in the hotpath, as can be seen for example in sja1105: Before: 000006dc <sja1105_xmit>: { 6dc: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr} 6e0: e1a04000 mov r4, r0 6e4: e591958c ldr r9, [r1, #1420] ; 0x58c <- Inline dsa_slave_to_port 6e8: e1a05001 mov r5, r1 6ec: e24dd004 sub sp, sp, #4 u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); 6f0: e1c901d8 ldrd r0, [r9, #24] 6f4: ebfffffe bl 0 <dsa_8021q_tx_vid> 6f4: R_ARM_CALL dsa_8021q_tx_vid u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); 6f8: e1d416b0 ldrh r1, [r4, #96] ; 0x60 u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); 6fc: e1a08000 mov r8, r0 After: 000006e4 <sja1105_xmit>: { 6e4: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr} 6e8: e1a04000 mov r4, r0 6ec: e24dd004 sub sp, sp, #4 struct dsa_port *dp = dsa_slave_to_port(netdev); 6f0: e1a00001 mov r0, r1 { 6f4: e1a05001 mov r5, r1 struct dsa_port *dp = dsa_slave_to_port(netdev); 6f8: ebfffffe bl 0 <dsa_slave_to_port> 6f8: R_ARM_CALL dsa_slave_to_port 6fc: e1a09000 mov r9, r0 u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); 700: e1c001d8 ldrd r0, [r0, #24] 704: ebfffffe bl 0 <dsa_8021q_tx_vid> 704: R_ARM_CALL dsa_8021q_tx_vid Because we want to avoid possible performance regressions, introduce this new function which is designed to be public. Suggested-by: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
bb206a0869
commit
e1eea81120
@ -637,6 +637,7 @@ void dsa_devlink_resource_occ_get_register(struct dsa_switch *ds,
|
|||||||
void *occ_get_priv);
|
void *occ_get_priv);
|
||||||
void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds,
|
void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds,
|
||||||
u64 resource_id);
|
u64 resource_id);
|
||||||
|
struct dsa_port *dsa_port_from_netdev(struct net_device *netdev);
|
||||||
|
|
||||||
struct dsa_devlink_priv {
|
struct dsa_devlink_priv {
|
||||||
struct dsa_switch *ds;
|
struct dsa_switch *ds;
|
||||||
|
@ -412,6 +412,15 @@ void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(dsa_devlink_resource_occ_get_unregister);
|
EXPORT_SYMBOL_GPL(dsa_devlink_resource_occ_get_unregister);
|
||||||
|
|
||||||
|
struct dsa_port *dsa_port_from_netdev(struct net_device *netdev)
|
||||||
|
{
|
||||||
|
if (!netdev || !dsa_slave_dev_check(netdev))
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
|
return dsa_slave_to_port(netdev);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dsa_port_from_netdev);
|
||||||
|
|
||||||
static int __init dsa_init_module(void)
|
static int __init dsa_init_module(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user