@@ -36,7 +36,11 @@ enum {
36
36
PHYLINK_DISABLE_LINK ,
37
37
};
38
38
39
+ /**
40
+ * struct phylink - internal data type for phylink
41
+ */
39
42
struct phylink {
43
+ /* private: */
40
44
struct net_device * netdev ;
41
45
const struct phylink_mac_ops * ops ;
42
46
@@ -87,6 +91,13 @@ static inline bool linkmode_empty(const unsigned long *src)
87
91
return bitmap_empty (src , __ETHTOOL_LINK_MODE_MASK_NBITS );
88
92
}
89
93
94
+ /**
95
+ * phylink_set_port_modes() - set the port type modes in the ethtool mask
96
+ * @mask: ethtool link mode mask
97
+ *
98
+ * Sets all the port type modes in the ethtool mask. MAC drivers should
99
+ * use this in their 'validate' callback.
100
+ */
90
101
void phylink_set_port_modes (unsigned long * mask )
91
102
{
92
103
phylink_set (mask , TP );
@@ -496,6 +507,19 @@ static int phylink_register_sfp(struct phylink *pl, struct device_node *np)
496
507
return 0 ;
497
508
}
498
509
510
+ /**
511
+ * phylink_create() - create a phylink instance
512
+ * @ndev: a pointer to the &struct net_device
513
+ * @np: a pointer to a &struct device_node describing the network interface
514
+ * @iface: the desired link mode defined by &typedef phy_interface_t
515
+ * @ops: a pointer to a &struct phylink_mac_ops for the MAC.
516
+ *
517
+ * Create a new phylink instance, and parse the link parameters found in @np.
518
+ * This will parse in-band modes, fixed-link or SFP configuration.
519
+ *
520
+ * Returns a pointer to a &struct phylink, or an error-pointer value. Users
521
+ * must use IS_ERR() to check for errors from this function.
522
+ */
499
523
struct phylink * phylink_create (struct net_device * ndev , struct device_node * np ,
500
524
phy_interface_t iface ,
501
525
const struct phylink_mac_ops * ops )
@@ -548,6 +572,13 @@ struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
548
572
}
549
573
EXPORT_SYMBOL_GPL (phylink_create );
550
574
575
+ /**
576
+ * phylink_destroy() - cleanup and destroy the phylink instance
577
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
578
+ *
579
+ * Destroy a phylink instance. Any PHY that has been attached must have been
580
+ * cleaned up via phylink_disconnect_phy() prior to calling this function.
581
+ */
551
582
void phylink_destroy (struct phylink * pl )
552
583
{
553
584
if (pl -> sfp_bus )
@@ -644,6 +675,21 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
644
675
return 0 ;
645
676
}
646
677
678
+ /**
679
+ * phylink_connect_phy() - connect a PHY to the phylink instance
680
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
681
+ * @phy: a pointer to a &struct phy_device.
682
+ *
683
+ * Connect @phy to the phylink instance specified by @pl by calling
684
+ * phy_attach_direct(). Configure the @phy according to the MAC driver's
685
+ * capabilities, start the PHYLIB state machine and enable any interrupts
686
+ * that the PHY supports.
687
+ *
688
+ * This updates the phylink's ethtool supported and advertising link mode
689
+ * masks.
690
+ *
691
+ * Returns 0 on success or a negative errno.
692
+ */
647
693
int phylink_connect_phy (struct phylink * pl , struct phy_device * phy )
648
694
{
649
695
int ret ;
@@ -665,6 +711,17 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
665
711
}
666
712
EXPORT_SYMBOL_GPL (phylink_connect_phy );
667
713
714
+ /**
715
+ * phylink_of_phy_connect() - connect the PHY specified in the DT mode.
716
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
717
+ * @dn: a pointer to a &struct device_node.
718
+ *
719
+ * Connect the phy specified in the device node @dn to the phylink instance
720
+ * specified by @pl. Actions specified in phylink_connect_phy() will be
721
+ * performed.
722
+ *
723
+ * Returns 0 on success or a negative errno.
724
+ */
668
725
int phylink_of_phy_connect (struct phylink * pl , struct device_node * dn )
669
726
{
670
727
struct device_node * phy_node ;
@@ -706,6 +763,13 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
706
763
}
707
764
EXPORT_SYMBOL_GPL (phylink_of_phy_connect );
708
765
766
+ /**
767
+ * phylink_disconnect_phy() - disconnect any PHY attached to the phylink
768
+ * instance.
769
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
770
+ *
771
+ * Disconnect any current PHY from the phylink instance described by @pl.
772
+ */
709
773
void phylink_disconnect_phy (struct phylink * pl )
710
774
{
711
775
struct phy_device * phy ;
@@ -727,6 +791,14 @@ void phylink_disconnect_phy(struct phylink *pl)
727
791
}
728
792
EXPORT_SYMBOL_GPL (phylink_disconnect_phy );
729
793
794
+ /**
795
+ * phylink_mac_change() - notify phylink of a change in MAC state
796
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
797
+ * @up: indicates whether the link is currently up.
798
+ *
799
+ * The MAC driver should call this driver when the state of its link
800
+ * changes (eg, link failure, new negotiation results, etc.)
801
+ */
730
802
void phylink_mac_change (struct phylink * pl , bool up )
731
803
{
732
804
if (!up )
@@ -736,6 +808,14 @@ void phylink_mac_change(struct phylink *pl, bool up)
736
808
}
737
809
EXPORT_SYMBOL_GPL (phylink_mac_change );
738
810
811
+ /**
812
+ * phylink_start() - start a phylink instance
813
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
814
+ *
815
+ * Start the phylink instance specified by @pl, configuring the MAC for the
816
+ * desired link mode(s) and negotiation style. This should be called from the
817
+ * network device driver's &struct net_device_ops ndo_open() method.
818
+ */
739
819
void phylink_start (struct phylink * pl )
740
820
{
741
821
WARN_ON (!lockdep_rtnl_is_held ());
@@ -767,6 +847,15 @@ void phylink_start(struct phylink *pl)
767
847
}
768
848
EXPORT_SYMBOL_GPL (phylink_start );
769
849
850
+ /**
851
+ * phylink_stop() - stop a phylink instance
852
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
853
+ *
854
+ * Stop the phylink instance specified by @pl. This should be called from the
855
+ * network device driver's &struct net_device_ops ndo_stop() method. The
856
+ * network device's carrier state should not be changed prior to calling this
857
+ * function.
858
+ */
770
859
void phylink_stop (struct phylink * pl )
771
860
{
772
861
WARN_ON (!lockdep_rtnl_is_held ());
@@ -782,6 +871,15 @@ void phylink_stop(struct phylink *pl)
782
871
}
783
872
EXPORT_SYMBOL_GPL (phylink_stop );
784
873
874
+ /**
875
+ * phylink_ethtool_get_wol() - get the wake on lan parameters for the PHY
876
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
877
+ * @wol: a pointer to &struct ethtool_wolinfo to hold the read parameters
878
+ *
879
+ * Read the wake on lan parameters from the PHY attached to the phylink
880
+ * instance specified by @pl. If no PHY is currently attached, report no
881
+ * support for wake on lan.
882
+ */
785
883
void phylink_ethtool_get_wol (struct phylink * pl , struct ethtool_wolinfo * wol )
786
884
{
787
885
WARN_ON (!lockdep_rtnl_is_held ());
@@ -794,6 +892,17 @@ void phylink_ethtool_get_wol(struct phylink *pl, struct ethtool_wolinfo *wol)
794
892
}
795
893
EXPORT_SYMBOL_GPL (phylink_ethtool_get_wol );
796
894
895
+ /**
896
+ * phylink_ethtool_set_wol() - set wake on lan parameters
897
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
898
+ * @wol: a pointer to &struct ethtool_wolinfo for the desired parameters
899
+ *
900
+ * Set the wake on lan parameters for the PHY attached to the phylink
901
+ * instance specified by @pl. If no PHY is attached, returns %EOPNOTSUPP
902
+ * error.
903
+ *
904
+ * Returns zero on success or negative errno code.
905
+ */
797
906
int phylink_ethtool_set_wol (struct phylink * pl , struct ethtool_wolinfo * wol )
798
907
{
799
908
int ret = - EOPNOTSUPP ;
@@ -829,6 +938,15 @@ static void phylink_get_ksettings(const struct phylink_link_state *state,
829
938
AUTONEG_DISABLE ;
830
939
}
831
940
941
+ /**
942
+ * phylink_ethtool_ksettings_get() - get the current link settings
943
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
944
+ * @kset: a pointer to a &struct ethtool_link_ksettings to hold link settings
945
+ *
946
+ * Read the current link settings for the phylink instance specified by @pl.
947
+ * This will be the link settings read from the MAC, PHY or fixed link
948
+ * settings depending on the current negotiation mode.
949
+ */
832
950
int phylink_ethtool_ksettings_get (struct phylink * pl ,
833
951
struct ethtool_link_ksettings * kset )
834
952
{
@@ -875,6 +993,11 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
875
993
}
876
994
EXPORT_SYMBOL_GPL (phylink_ethtool_ksettings_get );
877
995
996
+ /**
997
+ * phylink_ethtool_ksettings_set() - set the link settings
998
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
999
+ * @kset: a pointer to a &struct ethtool_link_ksettings for the desired modes
1000
+ */
878
1001
int phylink_ethtool_ksettings_set (struct phylink * pl ,
879
1002
const struct ethtool_link_ksettings * kset )
880
1003
{
@@ -968,6 +1091,17 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
968
1091
}
969
1092
EXPORT_SYMBOL_GPL (phylink_ethtool_ksettings_set );
970
1093
1094
+ /**
1095
+ * phylink_ethtool_nway_reset() - restart negotiation
1096
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1097
+ *
1098
+ * Restart negotiation for the phylink instance specified by @pl. This will
1099
+ * cause any attached phy to restart negotiation with the link partner, and
1100
+ * if the MAC is in a BaseX mode, the MAC will also be requested to restart
1101
+ * negotiation.
1102
+ *
1103
+ * Returns zero on success, or negative error code.
1104
+ */
971
1105
int phylink_ethtool_nway_reset (struct phylink * pl )
972
1106
{
973
1107
int ret = 0 ;
@@ -982,6 +1116,11 @@ int phylink_ethtool_nway_reset(struct phylink *pl)
982
1116
}
983
1117
EXPORT_SYMBOL_GPL (phylink_ethtool_nway_reset );
984
1118
1119
+ /**
1120
+ * phylink_ethtool_get_pauseparam() - get the current pause parameters
1121
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1122
+ * @pause: a pointer to a &struct ethtool_pauseparam
1123
+ */
985
1124
void phylink_ethtool_get_pauseparam (struct phylink * pl ,
986
1125
struct ethtool_pauseparam * pause )
987
1126
{
@@ -993,6 +1132,11 @@ void phylink_ethtool_get_pauseparam(struct phylink *pl,
993
1132
}
994
1133
EXPORT_SYMBOL_GPL (phylink_ethtool_get_pauseparam );
995
1134
1135
+ /**
1136
+ * phylink_ethtool_set_pauseparam() - set the current pause parameters
1137
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1138
+ * @pause: a pointer to a &struct ethtool_pauseparam
1139
+ */
996
1140
int phylink_ethtool_set_pauseparam (struct phylink * pl ,
997
1141
struct ethtool_pauseparam * pause )
998
1142
{
@@ -1070,6 +1214,16 @@ int phylink_ethtool_get_module_eeprom(struct phylink *pl,
1070
1214
}
1071
1215
EXPORT_SYMBOL_GPL (phylink_ethtool_get_module_eeprom );
1072
1216
1217
+ /**
1218
+ * phylink_ethtool_get_eee_err() - read the energy efficient ethernet error
1219
+ * counter
1220
+ * @pl: a pointer to a &struct phylink returned from phylink_create().
1221
+ *
1222
+ * Read the Energy Efficient Ethernet error counter from the PHY associated
1223
+ * with the phylink instance specified by @pl.
1224
+ *
1225
+ * Returns positive error counter value, or negative error code.
1226
+ */
1073
1227
int phylink_get_eee_err (struct phylink * pl )
1074
1228
{
1075
1229
int ret = 0 ;
@@ -1083,6 +1237,11 @@ int phylink_get_eee_err(struct phylink *pl)
1083
1237
}
1084
1238
EXPORT_SYMBOL_GPL (phylink_get_eee_err );
1085
1239
1240
+ /**
1241
+ * phylink_ethtool_get_eee() - read the energy efficient ethernet parameters
1242
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1243
+ * @eee: a pointer to a &struct ethtool_eee for the read parameters
1244
+ */
1086
1245
int phylink_ethtool_get_eee (struct phylink * pl , struct ethtool_eee * eee )
1087
1246
{
1088
1247
int ret = - EOPNOTSUPP ;
@@ -1096,6 +1255,11 @@ int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_eee *eee)
1096
1255
}
1097
1256
EXPORT_SYMBOL_GPL (phylink_ethtool_get_eee );
1098
1257
1258
+ /**
1259
+ * phylink_ethtool_set_eee() - set the energy efficient ethernet parameters
1260
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1261
+ * @eee: a pointer to a &struct ethtool_eee for the desired parameters
1262
+ */
1099
1263
int phylink_ethtool_set_eee (struct phylink * pl , struct ethtool_eee * eee )
1100
1264
{
1101
1265
int ret = - EOPNOTSUPP ;
@@ -1267,6 +1431,24 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id,
1267
1431
return 0 ;
1268
1432
}
1269
1433
1434
+ /**
1435
+ * phylink_mii_ioctl() - generic mii ioctl interface
1436
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
1437
+ * @ifr: a pointer to a &struct ifreq for socket ioctls
1438
+ * @cmd: ioctl cmd to execute
1439
+ *
1440
+ * Perform the specified MII ioctl on the PHY attached to the phylink instance
1441
+ * specified by @pl. If no PHY is attached, emulate the presence of the PHY.
1442
+ *
1443
+ * Returns: zero on success or negative error code.
1444
+ *
1445
+ * %SIOCGMIIPHY:
1446
+ * read register from the current PHY.
1447
+ * %SIOCGMIIREG:
1448
+ * read register from the specified PHY.
1449
+ * %SIOCSMIIREG:
1450
+ * set a register on the specified PHY.
1451
+ */
1270
1452
int phylink_mii_ioctl (struct phylink * pl , struct ifreq * ifr , int cmd )
1271
1453
{
1272
1454
struct mii_ioctl_data * mii = if_mii (ifr );
0 commit comments