Skip to content

Commit

Permalink
net: ethernet: ti: cpsw_ale: Add cpsw_ale_restore() helper
Browse files Browse the repository at this point in the history
This can be used by device driver to restore ALE context.
The data produced by cpsw_ale_dump() can be passed to
cpsw_ale_restore().

This is required as on certain platforms the ALE context
is lost on low power suspend/resume.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Roger Quadros authored and David S. Miller committed Nov 7, 2022
1 parent fd23df7 commit eadb434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/net/ethernet/ti/cpsw_ale.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,16 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
}
}

void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
{
int i;

for (i = 0; i < ale->params.ale_entries; i++) {
cpsw_ale_write(ale, i, data);
data += ALE_ENTRY_WORDS;
}
}

u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale)
{
return ale ? ale->params.ale_entries : 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/ti/cpsw_ale.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
int control, int value);
void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data);
u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale);

static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
Expand Down

0 comments on commit eadb434

Please sign in to comment.