Skip to content

Commit 381d577

Browse files
kolacinskikarolanguy11
authored andcommitted
ice: Refactor ice_ptp_init_tx_*
Unify ice_ptp_init_tx_* functions for most of the MAC types except E82X. This simplifies the code for the future use with new MAC types. Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Karol Kolacinski <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 92456e7 commit 381d577

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

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

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -971,28 +971,6 @@ ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
971971
tx->len = 0;
972972
}
973973

974-
/**
975-
* ice_ptp_init_tx_eth56g - Initialize tracking for Tx timestamps
976-
* @pf: Board private structure
977-
* @tx: the Tx tracking structure to initialize
978-
* @port: the port this structure tracks
979-
*
980-
* Initialize the Tx timestamp tracker for this port. ETH56G PHYs
981-
* have independent memory blocks for all ports.
982-
*
983-
* Return: 0 for success, -ENOMEM when failed to allocate Tx tracker
984-
*/
985-
static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx,
986-
u8 port)
987-
{
988-
tx->block = port;
989-
tx->offset = 0;
990-
tx->len = INDEX_PER_PORT_ETH56G;
991-
tx->has_ready_bitmap = 1;
992-
993-
return ice_ptp_alloc_tx_tracker(tx);
994-
}
995-
996974
/**
997975
* ice_ptp_init_tx_e82x - Initialize tracking for Tx timestamps
998976
* @pf: Board private structure
@@ -1003,9 +981,11 @@ static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx,
1003981
* the timestamp block is shared for all ports in the same quad. To avoid
1004982
* ports using the same timestamp index, logically break the block of
1005983
* registers into chunks based on the port number.
984+
*
985+
* Return: 0 on success, -ENOMEM when out of memory
1006986
*/
1007-
static int
1008-
ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port)
987+
static int ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx,
988+
u8 port)
1009989
{
1010990
tx->block = ICE_GET_QUAD_NUM(port);
1011991
tx->offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT_E82X;
@@ -1016,24 +996,27 @@ ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port)
1016996
}
1017997

1018998
/**
1019-
* ice_ptp_init_tx_e810 - Initialize tracking for Tx timestamps
999+
* ice_ptp_init_tx - Initialize tracking for Tx timestamps
10201000
* @pf: Board private structure
10211001
* @tx: the Tx tracking structure to initialize
1002+
* @port: the port this structure tracks
1003+
*
1004+
* Initialize the Tx timestamp tracker for this PF. For all PHYs except E82X,
1005+
* each port has its own block of timestamps, independent of the other ports.
10221006
*
1023-
* Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1024-
* port has its own block of timestamps, independent of the other ports.
1007+
* Return: 0 on success, -ENOMEM when out of memory
10251008
*/
1026-
static int
1027-
ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx)
1009+
static int ice_ptp_init_tx(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port)
10281010
{
1029-
tx->block = pf->hw.port_info->lport;
1011+
tx->block = port;
10301012
tx->offset = 0;
1031-
tx->len = INDEX_PER_PORT_E810;
1013+
tx->len = INDEX_PER_PORT;
1014+
10321015
/* The E810 PHY does not provide a timestamp ready bitmap. Instead,
10331016
* verify new timestamps against cached copy of the last read
10341017
* timestamp.
10351018
*/
1036-
tx->has_ready_bitmap = 0;
1019+
tx->has_ready_bitmap = pf->hw.mac_type != ICE_MAC_E810;
10371020

10381021
return ice_ptp_alloc_tx_tracker(tx);
10391022
}
@@ -3235,6 +3218,8 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
32353218
* ice_ptp_init_port - Initialize PTP port structure
32363219
* @pf: Board private structure
32373220
* @ptp_port: PTP port structure
3221+
*
3222+
* Return: 0 on success, -ENODEV on invalid MAC type, -ENOMEM on failed alloc.
32383223
*/
32393224
static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
32403225
{
@@ -3244,16 +3229,13 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)
32443229

32453230
switch (hw->mac_type) {
32463231
case ICE_MAC_E810:
3247-
return ice_ptp_init_tx_e810(pf, &ptp_port->tx);
3232+
case ICE_MAC_GENERIC_3K_E825:
3233+
return ice_ptp_init_tx(pf, &ptp_port->tx, ptp_port->port_num);
32483234
case ICE_MAC_GENERIC:
32493235
kthread_init_delayed_work(&ptp_port->ov_work,
32503236
ice_ptp_wait_for_offsets);
3251-
32523237
return ice_ptp_init_tx_e82x(pf, &ptp_port->tx,
32533238
ptp_port->port_num);
3254-
case ICE_MAC_GENERIC_3K_E825:
3255-
return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx,
3256-
ptp_port->port_num);
32573239
default:
32583240
return -ENODEV;
32593241
}

drivers/net/ethernet/intel/ice/ice_ptp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ struct ice_ptp_tx {
128128
/* Quad and port information for initializing timestamp blocks */
129129
#define INDEX_PER_QUAD 64
130130
#define INDEX_PER_PORT_E82X 16
131-
#define INDEX_PER_PORT_E810 64
132-
#define INDEX_PER_PORT_ETH56G 64
131+
#define INDEX_PER_PORT 64
133132

134133
/**
135134
* struct ice_ptp_port - data used to initialize an external port for PTP

0 commit comments

Comments
 (0)