Merge branch 'net-stmmac-Stop-using-hard-coded-callbacks'
Jose Abreu says: ==================== net: stmmac: Stop using hard-coded callbacks This a starting point for a cleanup and re-organization of stmmac. In this series we stop using hard-coded callbacks along the code and use instead helpers which are defined in a single place ("hwif.h"). This brings several advantages: 1) Less typing :) 2) Guaranteed function pointer check 3) More flexibility By 2) we stop using the repeated pattern of: if (priv->hw->mac->some_func) priv->hw->mac->some_func(...) I didn't check but I expect the final .ko will be bigger with this series because *all* of function pointers are checked. Anyway, I hope this can make the code more readable and more flexible now. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
5da8baa3be
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "stmmac.h"
|
||||
|
||||
static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
||||
static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
||||
{
|
||||
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;
|
||||
unsigned int nopaged_len = skb_headlen(skb);
|
||||
|
@ -51,8 +51,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
tx_q->tx_skbuff_dma[entry].buf = des2;
|
||||
tx_q->tx_skbuff_dma[entry].len = bmax;
|
||||
/* do not close the descriptor and do not set own bit */
|
||||
priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
|
||||
0, false, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
|
||||
0, false, skb->len);
|
||||
|
||||
while (len != 0) {
|
||||
tx_q->tx_skbuff[entry] = NULL;
|
||||
|
@ -68,9 +68,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
return -1;
|
||||
tx_q->tx_skbuff_dma[entry].buf = des2;
|
||||
tx_q->tx_skbuff_dma[entry].len = bmax;
|
||||
priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum,
|
||||
STMMAC_CHAIN_MODE, 1,
|
||||
false, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 0, bmax, csum,
|
||||
STMMAC_CHAIN_MODE, 1, false, skb->len);
|
||||
len -= bmax;
|
||||
i++;
|
||||
} else {
|
||||
|
@ -83,9 +82,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
tx_q->tx_skbuff_dma[entry].buf = des2;
|
||||
tx_q->tx_skbuff_dma[entry].len = len;
|
||||
/* last descriptor can be set now */
|
||||
priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
|
||||
STMMAC_CHAIN_MODE, 1,
|
||||
true, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 0, len, csum,
|
||||
STMMAC_CHAIN_MODE, 1, true, skb->len);
|
||||
len = 0;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +93,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
return entry;
|
||||
}
|
||||
|
||||
static unsigned int stmmac_is_jumbo_frm(int len, int enh_desc)
|
||||
static unsigned int is_jumbo_frm(int len, int enh_desc)
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
|
||||
|
@ -107,7 +105,7 @@ static unsigned int stmmac_is_jumbo_frm(int len, int enh_desc)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr,
|
||||
static void init_dma_chain(void *des, dma_addr_t phy_addr,
|
||||
unsigned int size, unsigned int extend_desc)
|
||||
{
|
||||
/*
|
||||
|
@ -137,7 +135,7 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr,
|
|||
}
|
||||
}
|
||||
|
||||
static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
static void refill_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
{
|
||||
struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr;
|
||||
struct stmmac_priv *priv = rx_q->priv_data;
|
||||
|
@ -153,7 +151,7 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
|
|||
sizeof(struct dma_desc)));
|
||||
}
|
||||
|
||||
static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
static void clean_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
{
|
||||
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;
|
||||
struct stmmac_priv *priv = tx_q->priv_data;
|
||||
|
@ -171,9 +169,9 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
|
|||
}
|
||||
|
||||
const struct stmmac_mode_ops chain_mode_ops = {
|
||||
.init = stmmac_init_dma_chain,
|
||||
.is_jumbo_frm = stmmac_is_jumbo_frm,
|
||||
.jumbo_frm = stmmac_jumbo_frm,
|
||||
.refill_desc3 = stmmac_refill_desc3,
|
||||
.clean_desc3 = stmmac_clean_desc3,
|
||||
.init = init_dma_chain,
|
||||
.is_jumbo_frm = is_jumbo_frm,
|
||||
.jumbo_frm = jumbo_frm,
|
||||
.refill_desc3 = refill_desc3,
|
||||
.clean_desc3 = clean_desc3,
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#endif
|
||||
|
||||
#include "descs.h"
|
||||
#include "hwif.h"
|
||||
#include "mmc.h"
|
||||
|
||||
/* Synopsys Core versions */
|
||||
|
@ -377,197 +378,11 @@ struct dma_features {
|
|||
|
||||
#define JUMBO_LEN 9000
|
||||
|
||||
/* Descriptors helpers */
|
||||
struct stmmac_desc_ops {
|
||||
/* DMA RX descriptor ring initialization */
|
||||
void (*init_rx_desc) (struct dma_desc *p, int disable_rx_ic, int mode,
|
||||
int end);
|
||||
/* DMA TX descriptor ring initialization */
|
||||
void (*init_tx_desc) (struct dma_desc *p, int mode, int end);
|
||||
|
||||
/* Invoked by the xmit function to prepare the tx descriptor */
|
||||
void (*prepare_tx_desc) (struct dma_desc *p, int is_fs, int len,
|
||||
bool csum_flag, int mode, bool tx_own,
|
||||
bool ls, unsigned int tot_pkt_len);
|
||||
void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
|
||||
int len2, bool tx_own, bool ls,
|
||||
unsigned int tcphdrlen,
|
||||
unsigned int tcppayloadlen);
|
||||
/* Set/get the owner of the descriptor */
|
||||
void (*set_tx_owner) (struct dma_desc *p);
|
||||
int (*get_tx_owner) (struct dma_desc *p);
|
||||
/* Clean the tx descriptor as soon as the tx irq is received */
|
||||
void (*release_tx_desc) (struct dma_desc *p, int mode);
|
||||
/* Clear interrupt on tx frame completion. When this bit is
|
||||
* set an interrupt happens as soon as the frame is transmitted */
|
||||
void (*set_tx_ic)(struct dma_desc *p);
|
||||
/* Last tx segment reports the transmit status */
|
||||
int (*get_tx_ls) (struct dma_desc *p);
|
||||
/* Return the transmit status looking at the TDES1 */
|
||||
int (*tx_status) (void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_desc *p, void __iomem *ioaddr);
|
||||
/* Get the buffer size from the descriptor */
|
||||
int (*get_tx_len) (struct dma_desc *p);
|
||||
/* Handle extra events on specific interrupts hw dependent */
|
||||
void (*set_rx_owner) (struct dma_desc *p);
|
||||
/* Get the receive frame size */
|
||||
int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type);
|
||||
/* Return the reception status looking at the RDES1 */
|
||||
int (*rx_status) (void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_desc *p);
|
||||
void (*rx_extended_status) (void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_extended_desc *p);
|
||||
/* Set tx timestamp enable bit */
|
||||
void (*enable_tx_timestamp) (struct dma_desc *p);
|
||||
/* get tx timestamp status */
|
||||
int (*get_tx_timestamp_status) (struct dma_desc *p);
|
||||
/* get timestamp value */
|
||||
u64(*get_timestamp) (void *desc, u32 ats);
|
||||
/* get rx timestamp status */
|
||||
int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
|
||||
/* Display ring */
|
||||
void (*display_ring)(void *head, unsigned int size, bool rx);
|
||||
/* set MSS via context descriptor */
|
||||
void (*set_mss)(struct dma_desc *p, unsigned int mss);
|
||||
};
|
||||
|
||||
extern const struct stmmac_desc_ops enh_desc_ops;
|
||||
extern const struct stmmac_desc_ops ndesc_ops;
|
||||
|
||||
/* Specific DMA helpers */
|
||||
struct stmmac_dma_ops {
|
||||
/* DMA core initialization */
|
||||
int (*reset)(void __iomem *ioaddr);
|
||||
void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_tx, u32 dma_rx, int atds);
|
||||
void (*init_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg, u32 chan);
|
||||
void (*init_rx_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_rx_phy, u32 chan);
|
||||
void (*init_tx_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_tx_phy, u32 chan);
|
||||
/* Configure the AXI Bus Mode Register */
|
||||
void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi);
|
||||
/* Dump DMA registers */
|
||||
void (*dump_regs)(void __iomem *ioaddr, u32 *reg_space);
|
||||
/* Set tx/rx threshold in the csr6 register
|
||||
* An invalid value enables the store-and-forward mode */
|
||||
void (*dma_mode)(void __iomem *ioaddr, int txmode, int rxmode,
|
||||
int rxfifosz);
|
||||
void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel,
|
||||
int fifosz, u8 qmode);
|
||||
void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel,
|
||||
int fifosz, u8 qmode);
|
||||
/* To track extra statistic (if supported) */
|
||||
void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
|
||||
void __iomem *ioaddr);
|
||||
void (*enable_dma_transmission) (void __iomem *ioaddr);
|
||||
void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan);
|
||||
void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan);
|
||||
void (*start_tx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*stop_tx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*start_rx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*stop_rx)(void __iomem *ioaddr, u32 chan);
|
||||
int (*dma_interrupt) (void __iomem *ioaddr,
|
||||
struct stmmac_extra_stats *x, u32 chan);
|
||||
/* If supported then get the optional core features */
|
||||
void (*get_hw_feature)(void __iomem *ioaddr,
|
||||
struct dma_features *dma_cap);
|
||||
/* Program the HW RX Watchdog */
|
||||
void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan);
|
||||
void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
|
||||
void (*set_rx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
|
||||
void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
|
||||
};
|
||||
|
||||
struct mac_device_info;
|
||||
|
||||
/* Helpers to program the MAC core */
|
||||
struct stmmac_ops {
|
||||
/* MAC core initialization */
|
||||
void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
|
||||
/* Enable the MAC RX/TX */
|
||||
void (*set_mac)(void __iomem *ioaddr, bool enable);
|
||||
/* Enable and verify that the IPC module is supported */
|
||||
int (*rx_ipc)(struct mac_device_info *hw);
|
||||
/* Enable RX Queues */
|
||||
void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
|
||||
/* RX Queues Priority */
|
||||
void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
|
||||
/* TX Queues Priority */
|
||||
void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
|
||||
/* RX Queues Routing */
|
||||
void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet,
|
||||
u32 queue);
|
||||
/* Program RX Algorithms */
|
||||
void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
|
||||
/* Program TX Algorithms */
|
||||
void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
|
||||
/* Set MTL TX queues weight */
|
||||
void (*set_mtl_tx_queue_weight)(struct mac_device_info *hw,
|
||||
u32 weight, u32 queue);
|
||||
/* RX MTL queue to RX dma mapping */
|
||||
void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan);
|
||||
/* Configure AV Algorithm */
|
||||
void (*config_cbs)(struct mac_device_info *hw, u32 send_slope,
|
||||
u32 idle_slope, u32 high_credit, u32 low_credit,
|
||||
u32 queue);
|
||||
/* Dump MAC registers */
|
||||
void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
|
||||
/* Handle extra events on specific interrupts hw dependent */
|
||||
int (*host_irq_status)(struct mac_device_info *hw,
|
||||
struct stmmac_extra_stats *x);
|
||||
/* Handle MTL interrupts */
|
||||
int (*host_mtl_irq_status)(struct mac_device_info *hw, u32 chan);
|
||||
/* Multicast filter setting */
|
||||
void (*set_filter)(struct mac_device_info *hw, struct net_device *dev);
|
||||
/* Flow control setting */
|
||||
void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex,
|
||||
unsigned int fc, unsigned int pause_time, u32 tx_cnt);
|
||||
/* Set power management mode (e.g. magic frame) */
|
||||
void (*pmt)(struct mac_device_info *hw, unsigned long mode);
|
||||
/* Set/Get Unicast MAC addresses */
|
||||
void (*set_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
|
||||
unsigned int reg_n);
|
||||
void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
|
||||
unsigned int reg_n);
|
||||
void (*set_eee_mode)(struct mac_device_info *hw,
|
||||
bool en_tx_lpi_clockgating);
|
||||
void (*reset_eee_mode)(struct mac_device_info *hw);
|
||||
void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw);
|
||||
void (*set_eee_pls)(struct mac_device_info *hw, int link);
|
||||
void (*debug)(void __iomem *ioaddr, struct stmmac_extra_stats *x,
|
||||
u32 rx_queues, u32 tx_queues);
|
||||
/* PCS calls */
|
||||
void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral,
|
||||
bool loopback);
|
||||
void (*pcs_rane)(void __iomem *ioaddr, bool restart);
|
||||
void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
|
||||
/* Safety Features */
|
||||
int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp);
|
||||
bool (*safety_feat_irq_status)(struct net_device *ndev,
|
||||
void __iomem *ioaddr, unsigned int asp,
|
||||
struct stmmac_safety_stats *stats);
|
||||
const char *(*safety_feat_dump)(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count);
|
||||
};
|
||||
|
||||
/* PTP and HW Timer helpers */
|
||||
struct stmmac_hwtimestamp {
|
||||
void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
|
||||
u32 (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock,
|
||||
int gmac4);
|
||||
int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
|
||||
int (*config_addend) (void __iomem *ioaddr, u32 addend);
|
||||
int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec,
|
||||
int add_sub, int gmac4);
|
||||
u64(*get_systime) (void __iomem *ioaddr);
|
||||
};
|
||||
|
||||
extern const struct stmmac_hwtimestamp stmmac_ptp;
|
||||
extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;
|
||||
|
||||
|
@ -590,18 +405,6 @@ struct mii_regs {
|
|||
unsigned int clk_csr_mask;
|
||||
};
|
||||
|
||||
/* Helpers to manage the descriptors for chain and ring modes */
|
||||
struct stmmac_mode_ops {
|
||||
void (*init) (void *des, dma_addr_t phy_addr, unsigned int size,
|
||||
unsigned int extend_desc);
|
||||
unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
|
||||
int (*jumbo_frm)(void *priv, struct sk_buff *skb, int csum);
|
||||
int (*set_16kib_bfsize)(int mtu);
|
||||
void (*init_desc3)(struct dma_desc *p);
|
||||
void (*refill_desc3) (void *priv, struct dma_desc *p);
|
||||
void (*clean_desc3) (void *priv, struct dma_desc *p);
|
||||
};
|
||||
|
||||
struct mac_device_info {
|
||||
const struct stmmac_ops *mac;
|
||||
const struct stmmac_desc_ops *desc;
|
||||
|
|
|
@ -223,7 +223,7 @@ static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline u64 dwmac4_get_timestamp(void *desc, u32 ats)
|
||||
static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
|
||||
{
|
||||
struct dma_desc *p = (struct dma_desc *)desc;
|
||||
u64 ns;
|
||||
|
@ -232,7 +232,7 @@ static inline u64 dwmac4_get_timestamp(void *desc, u32 ats)
|
|||
/* convert high/sec time stamp value to nanosecond */
|
||||
ns += le32_to_cpu(p->des1) * 1000000000ULL;
|
||||
|
||||
return ns;
|
||||
*ts = ns;
|
||||
}
|
||||
|
||||
static int dwmac4_rx_check_timestamp(void *desc)
|
||||
|
|
|
@ -237,15 +237,16 @@ int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool dwmac5_safety_feat_irq_status(struct net_device *ndev,
|
||||
int dwmac5_safety_feat_irq_status(struct net_device *ndev,
|
||||
void __iomem *ioaddr, unsigned int asp,
|
||||
struct stmmac_safety_stats *stats)
|
||||
{
|
||||
bool ret = false, err, corr;
|
||||
bool err, corr;
|
||||
u32 mtl, dma;
|
||||
int ret = 0;
|
||||
|
||||
if (!asp)
|
||||
return false;
|
||||
return -EINVAL;
|
||||
|
||||
mtl = readl(ioaddr + MTL_SAFETY_INT_STATUS);
|
||||
dma = readl(ioaddr + DMA_SAFETY_INT_STATUS);
|
||||
|
@ -282,17 +283,19 @@ static const struct dwmac5_error {
|
|||
{ dwmac5_dma_errors },
|
||||
};
|
||||
|
||||
const char *dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count)
|
||||
int dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count, const char **desc)
|
||||
{
|
||||
int module = index / 32, offset = index % 32;
|
||||
unsigned long *ptr = (unsigned long *)stats;
|
||||
|
||||
if (module >= ARRAY_SIZE(dwmac5_all_errors))
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
if (!dwmac5_all_errors[module].desc[offset].valid)
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
if (count)
|
||||
*count = *(ptr + index);
|
||||
return dwmac5_all_errors[module].desc[offset].desc;
|
||||
if (desc)
|
||||
*desc = dwmac5_all_errors[module].desc[offset].desc;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
#define DMA_ECC_INT_STATUS 0x00001088
|
||||
|
||||
int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp);
|
||||
bool dwmac5_safety_feat_irq_status(struct net_device *ndev,
|
||||
int dwmac5_safety_feat_irq_status(struct net_device *ndev,
|
||||
void __iomem *ioaddr, unsigned int asp,
|
||||
struct stmmac_safety_stats *stats);
|
||||
const char *dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count);
|
||||
int dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count, const char **desc);
|
||||
|
||||
#endif /* __DWMAC5_H__ */
|
||||
|
|
|
@ -382,7 +382,7 @@ static int enh_desc_get_tx_timestamp_status(struct dma_desc *p)
|
|||
return (le32_to_cpu(p->des0) & ETDES0_TIME_STAMP_STATUS) >> 17;
|
||||
}
|
||||
|
||||
static u64 enh_desc_get_timestamp(void *desc, u32 ats)
|
||||
static void enh_desc_get_timestamp(void *desc, u32 ats, u64 *ts)
|
||||
{
|
||||
u64 ns;
|
||||
|
||||
|
@ -397,7 +397,7 @@ static u64 enh_desc_get_timestamp(void *desc, u32 ats)
|
|||
ns += le32_to_cpu(p->des3) * 1000000000ULL;
|
||||
}
|
||||
|
||||
return ns;
|
||||
*ts = ns;
|
||||
}
|
||||
|
||||
static int enh_desc_get_rx_timestamp_status(void *desc, void *next_desc,
|
||||
|
|
|
@ -0,0 +1,421 @@
|
|||
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
// Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
|
||||
// stmmac HW Interface Callbacks
|
||||
|
||||
#ifndef __STMMAC_HWIF_H__
|
||||
#define __STMMAC_HWIF_H__
|
||||
|
||||
#define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \
|
||||
({ \
|
||||
int __result = -EINVAL; \
|
||||
if ((__priv)->hw->__module->__cname) { \
|
||||
(__priv)->hw->__module->__cname((__arg0), ##__args); \
|
||||
__result = 0; \
|
||||
} \
|
||||
__result; \
|
||||
})
|
||||
#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \
|
||||
({ \
|
||||
int __result = -EINVAL; \
|
||||
if ((__priv)->hw->__module->__cname) \
|
||||
__result = (__priv)->hw->__module->__cname((__arg0), ##__args); \
|
||||
__result; \
|
||||
})
|
||||
|
||||
struct stmmac_extra_stats;
|
||||
struct stmmac_safety_stats;
|
||||
struct dma_desc;
|
||||
struct dma_extended_desc;
|
||||
|
||||
/* Descriptors helpers */
|
||||
struct stmmac_desc_ops {
|
||||
/* DMA RX descriptor ring initialization */
|
||||
void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode,
|
||||
int end);
|
||||
/* DMA TX descriptor ring initialization */
|
||||
void (*init_tx_desc)(struct dma_desc *p, int mode, int end);
|
||||
/* Invoked by the xmit function to prepare the tx descriptor */
|
||||
void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len,
|
||||
bool csum_flag, int mode, bool tx_own, bool ls,
|
||||
unsigned int tot_pkt_len);
|
||||
void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
|
||||
int len2, bool tx_own, bool ls, unsigned int tcphdrlen,
|
||||
unsigned int tcppayloadlen);
|
||||
/* Set/get the owner of the descriptor */
|
||||
void (*set_tx_owner)(struct dma_desc *p);
|
||||
int (*get_tx_owner)(struct dma_desc *p);
|
||||
/* Clean the tx descriptor as soon as the tx irq is received */
|
||||
void (*release_tx_desc)(struct dma_desc *p, int mode);
|
||||
/* Clear interrupt on tx frame completion. When this bit is
|
||||
* set an interrupt happens as soon as the frame is transmitted */
|
||||
void (*set_tx_ic)(struct dma_desc *p);
|
||||
/* Last tx segment reports the transmit status */
|
||||
int (*get_tx_ls)(struct dma_desc *p);
|
||||
/* Return the transmit status looking at the TDES1 */
|
||||
int (*tx_status)(void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_desc *p, void __iomem *ioaddr);
|
||||
/* Get the buffer size from the descriptor */
|
||||
int (*get_tx_len)(struct dma_desc *p);
|
||||
/* Handle extra events on specific interrupts hw dependent */
|
||||
void (*set_rx_owner)(struct dma_desc *p);
|
||||
/* Get the receive frame size */
|
||||
int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type);
|
||||
/* Return the reception status looking at the RDES1 */
|
||||
int (*rx_status)(void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_desc *p);
|
||||
void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x,
|
||||
struct dma_extended_desc *p);
|
||||
/* Set tx timestamp enable bit */
|
||||
void (*enable_tx_timestamp) (struct dma_desc *p);
|
||||
/* get tx timestamp status */
|
||||
int (*get_tx_timestamp_status) (struct dma_desc *p);
|
||||
/* get timestamp value */
|
||||
void (*get_timestamp)(void *desc, u32 ats, u64 *ts);
|
||||
/* get rx timestamp status */
|
||||
int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
|
||||
/* Display ring */
|
||||
void (*display_ring)(void *head, unsigned int size, bool rx);
|
||||
/* set MSS via context descriptor */
|
||||
void (*set_mss)(struct dma_desc *p, unsigned int mss);
|
||||
};
|
||||
|
||||
#define stmmac_init_rx_desc(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, init_rx_desc, __args)
|
||||
#define stmmac_init_tx_desc(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, init_tx_desc, __args)
|
||||
#define stmmac_prepare_tx_desc(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args)
|
||||
#define stmmac_prepare_tso_tx_desc(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args)
|
||||
#define stmmac_set_tx_owner(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, set_tx_owner, __args)
|
||||
#define stmmac_get_tx_owner(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_tx_owner, __args)
|
||||
#define stmmac_release_tx_desc(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, release_tx_desc, __args)
|
||||
#define stmmac_set_tx_ic(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, set_tx_ic, __args)
|
||||
#define stmmac_get_tx_ls(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_tx_ls, __args)
|
||||
#define stmmac_tx_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, tx_status, __args)
|
||||
#define stmmac_get_tx_len(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_tx_len, __args)
|
||||
#define stmmac_set_rx_owner(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
|
||||
#define stmmac_get_rx_frame_len(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
|
||||
#define stmmac_rx_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, rx_status, __args)
|
||||
#define stmmac_rx_extended_status(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, rx_extended_status, __args)
|
||||
#define stmmac_enable_tx_timestamp(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args)
|
||||
#define stmmac_get_tx_timestamp_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args)
|
||||
#define stmmac_get_timestamp(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, get_timestamp, __args)
|
||||
#define stmmac_get_rx_timestamp_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args)
|
||||
#define stmmac_display_ring(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, display_ring, __args)
|
||||
#define stmmac_set_mss(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, desc, set_mss, __args)
|
||||
|
||||
struct stmmac_dma_cfg;
|
||||
struct dma_features;
|
||||
|
||||
/* Specific DMA helpers */
|
||||
struct stmmac_dma_ops {
|
||||
/* DMA core initialization */
|
||||
int (*reset)(void __iomem *ioaddr);
|
||||
void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_tx, u32 dma_rx, int atds);
|
||||
void (*init_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg, u32 chan);
|
||||
void (*init_rx_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_rx_phy, u32 chan);
|
||||
void (*init_tx_chan)(void __iomem *ioaddr,
|
||||
struct stmmac_dma_cfg *dma_cfg,
|
||||
u32 dma_tx_phy, u32 chan);
|
||||
/* Configure the AXI Bus Mode Register */
|
||||
void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi);
|
||||
/* Dump DMA registers */
|
||||
void (*dump_regs)(void __iomem *ioaddr, u32 *reg_space);
|
||||
/* Set tx/rx threshold in the csr6 register
|
||||
* An invalid value enables the store-and-forward mode */
|
||||
void (*dma_mode)(void __iomem *ioaddr, int txmode, int rxmode,
|
||||
int rxfifosz);
|
||||
void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel,
|
||||
int fifosz, u8 qmode);
|
||||
void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel,
|
||||
int fifosz, u8 qmode);
|
||||
/* To track extra statistic (if supported) */
|
||||
void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
|
||||
void __iomem *ioaddr);
|
||||
void (*enable_dma_transmission) (void __iomem *ioaddr);
|
||||
void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan);
|
||||
void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan);
|
||||
void (*start_tx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*stop_tx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*start_rx)(void __iomem *ioaddr, u32 chan);
|
||||
void (*stop_rx)(void __iomem *ioaddr, u32 chan);
|
||||
int (*dma_interrupt) (void __iomem *ioaddr,
|
||||
struct stmmac_extra_stats *x, u32 chan);
|
||||
/* If supported then get the optional core features */
|
||||
void (*get_hw_feature)(void __iomem *ioaddr,
|
||||
struct dma_features *dma_cap);
|
||||
/* Program the HW RX Watchdog */
|
||||
void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan);
|
||||
void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
|
||||
void (*set_rx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
|
||||
void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
|
||||
};
|
||||
|
||||
#define stmmac_reset(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, dma, reset, __args)
|
||||
#define stmmac_dma_init(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, init, __args)
|
||||
#define stmmac_init_chan(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, init_chan, __args)
|
||||
#define stmmac_init_rx_chan(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, init_rx_chan, __args)
|
||||
#define stmmac_init_tx_chan(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, init_tx_chan, __args)
|
||||
#define stmmac_axi(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, axi, __args)
|
||||
#define stmmac_dump_dma_regs(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, dump_regs, __args)
|
||||
#define stmmac_dma_mode(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, dma_mode, __args)
|
||||
#define stmmac_dma_rx_mode(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, dma_rx_mode, __args)
|
||||
#define stmmac_dma_tx_mode(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, dma_tx_mode, __args)
|
||||
#define stmmac_dma_diagnostic_fr(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
|
||||
#define stmmac_enable_dma_transmission(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
|
||||
#define stmmac_enable_dma_irq(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, enable_dma_irq, __args)
|
||||
#define stmmac_disable_dma_irq(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, disable_dma_irq, __args)
|
||||
#define stmmac_start_tx(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, start_tx, __args)
|
||||
#define stmmac_stop_tx(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, stop_tx, __args)
|
||||
#define stmmac_start_rx(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, start_rx, __args)
|
||||
#define stmmac_stop_rx(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, stop_rx, __args)
|
||||
#define stmmac_dma_interrupt_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, dma, dma_interrupt, __args)
|
||||
#define stmmac_get_hw_feature(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, get_hw_feature, __args)
|
||||
#define stmmac_rx_watchdog(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, rx_watchdog, __args)
|
||||
#define stmmac_set_tx_ring_len(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, set_tx_ring_len, __args)
|
||||
#define stmmac_set_rx_ring_len(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, set_rx_ring_len, __args)
|
||||
#define stmmac_set_rx_tail_ptr(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, set_rx_tail_ptr, __args)
|
||||
#define stmmac_set_tx_tail_ptr(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __args)
|
||||
#define stmmac_enable_tso(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, enable_tso, __args)
|
||||
|
||||
struct mac_device_info;
|
||||
struct net_device;
|
||||
struct rgmii_adv;
|
||||
struct stmmac_safety_stats;
|
||||
|
||||
/* Helpers to program the MAC core */
|
||||
struct stmmac_ops {
|
||||
/* MAC core initialization */
|
||||
void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
|
||||
/* Enable the MAC RX/TX */
|
||||
void (*set_mac)(void __iomem *ioaddr, bool enable);
|
||||
/* Enable and verify that the IPC module is supported */
|
||||
int (*rx_ipc)(struct mac_device_info *hw);
|
||||
/* Enable RX Queues */
|
||||
void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
|
||||
/* RX Queues Priority */
|
||||
void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
|
||||
/* TX Queues Priority */
|
||||
void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
|
||||
/* RX Queues Routing */
|
||||
void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet,
|
||||
u32 queue);
|
||||
/* Program RX Algorithms */
|
||||
void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
|
||||
/* Program TX Algorithms */
|
||||
void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
|
||||
/* Set MTL TX queues weight */
|
||||
void (*set_mtl_tx_queue_weight)(struct mac_device_info *hw,
|
||||
u32 weight, u32 queue);
|
||||
/* RX MTL queue to RX dma mapping */
|
||||
void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan);
|
||||
/* Configure AV Algorithm */
|
||||
void (*config_cbs)(struct mac_device_info *hw, u32 send_slope,
|
||||
u32 idle_slope, u32 high_credit, u32 low_credit,
|
||||
u32 queue);
|
||||
/* Dump MAC registers */
|
||||
void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
|
||||
/* Handle extra events on specific interrupts hw dependent */
|
||||
int (*host_irq_status)(struct mac_device_info *hw,
|
||||
struct stmmac_extra_stats *x);
|
||||
/* Handle MTL interrupts */
|
||||
int (*host_mtl_irq_status)(struct mac_device_info *hw, u32 chan);
|
||||
/* Multicast filter setting */
|
||||
void (*set_filter)(struct mac_device_info *hw, struct net_device *dev);
|
||||
/* Flow control setting */
|
||||
void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex,
|
||||
unsigned int fc, unsigned int pause_time, u32 tx_cnt);
|
||||
/* Set power management mode (e.g. magic frame) */
|
||||
void (*pmt)(struct mac_device_info *hw, unsigned long mode);
|
||||
/* Set/Get Unicast MAC addresses */
|
||||
void (*set_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
|
||||
unsigned int reg_n);
|
||||
void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
|
||||
unsigned int reg_n);
|
||||
void (*set_eee_mode)(struct mac_device_info *hw,
|
||||
bool en_tx_lpi_clockgating);
|
||||
void (*reset_eee_mode)(struct mac_device_info *hw);
|
||||
void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw);
|
||||
void (*set_eee_pls)(struct mac_device_info *hw, int link);
|
||||
void (*debug)(void __iomem *ioaddr, struct stmmac_extra_stats *x,
|
||||
u32 rx_queues, u32 tx_queues);
|
||||
/* PCS calls */
|
||||
void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral,
|
||||
bool loopback);
|
||||
void (*pcs_rane)(void __iomem *ioaddr, bool restart);
|
||||
void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
|
||||
/* Safety Features */
|
||||
int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp);
|
||||
int (*safety_feat_irq_status)(struct net_device *ndev,
|
||||
void __iomem *ioaddr, unsigned int asp,
|
||||
struct stmmac_safety_stats *stats);
|
||||
int (*safety_feat_dump)(struct stmmac_safety_stats *stats,
|
||||
int index, unsigned long *count, const char **desc);
|
||||
};
|
||||
|
||||
#define stmmac_core_init(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, core_init, __args)
|
||||
#define stmmac_mac_set(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_mac, __args)
|
||||
#define stmmac_rx_ipc(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, rx_ipc, __args)
|
||||
#define stmmac_rx_queue_enable(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, rx_queue_enable, __args)
|
||||
#define stmmac_rx_queue_prio(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, rx_queue_prio, __args)
|
||||
#define stmmac_tx_queue_prio(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, tx_queue_prio, __args)
|
||||
#define stmmac_rx_queue_routing(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, rx_queue_routing, __args)
|
||||
#define stmmac_prog_mtl_rx_algorithms(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, prog_mtl_rx_algorithms, __args)
|
||||
#define stmmac_prog_mtl_tx_algorithms(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, prog_mtl_tx_algorithms, __args)
|
||||
#define stmmac_set_mtl_tx_queue_weight(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_mtl_tx_queue_weight, __args)
|
||||
#define stmmac_map_mtl_to_dma(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, map_mtl_to_dma, __args)
|
||||
#define stmmac_config_cbs(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, config_cbs, __args)
|
||||
#define stmmac_dump_mac_regs(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, dump_regs, __args)
|
||||
#define stmmac_host_irq_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, host_irq_status, __args)
|
||||
#define stmmac_host_mtl_irq_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, host_mtl_irq_status, __args)
|
||||
#define stmmac_set_filter(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_filter, __args)
|
||||
#define stmmac_flow_ctrl(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, flow_ctrl, __args)
|
||||
#define stmmac_pmt(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, pmt, __args)
|
||||
#define stmmac_set_umac_addr(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_umac_addr, __args)
|
||||
#define stmmac_get_umac_addr(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, get_umac_addr, __args)
|
||||
#define stmmac_set_eee_mode(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_eee_mode, __args)
|
||||
#define stmmac_reset_eee_mode(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args)
|
||||
#define stmmac_set_eee_timer(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_eee_timer, __args)
|
||||
#define stmmac_set_eee_pls(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_eee_pls, __args)
|
||||
#define stmmac_mac_debug(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, debug, __args)
|
||||
#define stmmac_pcs_ctrl_ane(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args)
|
||||
#define stmmac_pcs_rane(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, pcs_rane, __args)
|
||||
#define stmmac_pcs_get_adv_lp(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args)
|
||||
#define stmmac_safety_feat_config(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, safety_feat_config, __args)
|
||||
#define stmmac_safety_feat_irq_status(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, safety_feat_irq_status, __args)
|
||||
#define stmmac_safety_feat_dump(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mac, safety_feat_dump, __args)
|
||||
|
||||
/* PTP and HW Timer helpers */
|
||||
struct stmmac_hwtimestamp {
|
||||
void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
|
||||
void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock,
|
||||
int gmac4, u32 *ssinc);
|
||||
int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
|
||||
int (*config_addend) (void __iomem *ioaddr, u32 addend);
|
||||
int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec,
|
||||
int add_sub, int gmac4);
|
||||
void (*get_systime) (void __iomem *ioaddr, u64 *systime);
|
||||
};
|
||||
|
||||
#define stmmac_config_hw_tstamping(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args)
|
||||
#define stmmac_config_sub_second_increment(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args)
|
||||
#define stmmac_init_systime(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, ptp, init_systime, __args)
|
||||
#define stmmac_config_addend(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, ptp, config_addend, __args)
|
||||
#define stmmac_adjust_systime(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, ptp, adjust_systime, __args)
|
||||
#define stmmac_get_systime(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, ptp, get_systime, __args)
|
||||
|
||||
/* Helpers to manage the descriptors for chain and ring modes */
|
||||
struct stmmac_mode_ops {
|
||||
void (*init) (void *des, dma_addr_t phy_addr, unsigned int size,
|
||||
unsigned int extend_desc);
|
||||
unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
|
||||
int (*jumbo_frm)(void *priv, struct sk_buff *skb, int csum);
|
||||
int (*set_16kib_bfsize)(int mtu);
|
||||
void (*init_desc3)(struct dma_desc *p);
|
||||
void (*refill_desc3) (void *priv, struct dma_desc *p);
|
||||
void (*clean_desc3) (void *priv, struct dma_desc *p);
|
||||
};
|
||||
|
||||
#define stmmac_mode_init(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mode, init, __args)
|
||||
#define stmmac_is_jumbo_frm(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mode, is_jumbo_frm, __args)
|
||||
#define stmmac_jumbo_frm(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mode, jumbo_frm, __args)
|
||||
#define stmmac_set_16kib_bfsize(__priv, __args...) \
|
||||
stmmac_do_callback(__priv, mode, set_16kib_bfsize, __args)
|
||||
#define stmmac_init_desc3(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mode, init_desc3, __args)
|
||||
#define stmmac_refill_desc3(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mode, refill_desc3, __args)
|
||||
#define stmmac_clean_desc3(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mode, clean_desc3, __args)
|
||||
|
||||
#endif /* __STMMAC_HWIF_H__ */
|
|
@ -253,7 +253,7 @@ static int ndesc_get_tx_timestamp_status(struct dma_desc *p)
|
|||
return (le32_to_cpu(p->des0) & TDES0_TIME_STAMP_STATUS) >> 17;
|
||||
}
|
||||
|
||||
static u64 ndesc_get_timestamp(void *desc, u32 ats)
|
||||
static void ndesc_get_timestamp(void *desc, u32 ats, u64 *ts)
|
||||
{
|
||||
struct dma_desc *p = (struct dma_desc *)desc;
|
||||
u64 ns;
|
||||
|
@ -262,7 +262,7 @@ static u64 ndesc_get_timestamp(void *desc, u32 ats)
|
|||
/* convert high/sec time stamp value to nanosecond */
|
||||
ns += le32_to_cpu(p->des3) * 1000000000ULL;
|
||||
|
||||
return ns;
|
||||
*ts = ns;
|
||||
}
|
||||
|
||||
static int ndesc_get_rx_timestamp_status(void *desc, void *next_desc, u32 ats)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "stmmac.h"
|
||||
|
||||
static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
||||
static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
||||
{
|
||||
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;
|
||||
unsigned int nopaged_len = skb_headlen(skb);
|
||||
|
@ -58,9 +58,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
|
||||
|
||||
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
|
||||
priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum,
|
||||
STMMAC_RING_MODE, 0,
|
||||
false, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum,
|
||||
STMMAC_RING_MODE, 0, false, skb->len);
|
||||
tx_q->tx_skbuff[entry] = NULL;
|
||||
entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
|
||||
|
||||
|
@ -79,9 +78,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
|
||||
|
||||
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
|
||||
priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
|
||||
STMMAC_RING_MODE, 1,
|
||||
true, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 0, len, csum,
|
||||
STMMAC_RING_MODE, 1, true, skb->len);
|
||||
} else {
|
||||
des2 = dma_map_single(priv->device, skb->data,
|
||||
nopaged_len, DMA_TO_DEVICE);
|
||||
|
@ -92,9 +90,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
tx_q->tx_skbuff_dma[entry].len = nopaged_len;
|
||||
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
|
||||
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
|
||||
priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum,
|
||||
STMMAC_RING_MODE, 0,
|
||||
true, skb->len);
|
||||
stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum,
|
||||
STMMAC_RING_MODE, 0, true, skb->len);
|
||||
}
|
||||
|
||||
tx_q->cur_tx = entry;
|
||||
|
@ -102,7 +99,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
|
|||
return entry;
|
||||
}
|
||||
|
||||
static unsigned int stmmac_is_jumbo_frm(int len, int enh_desc)
|
||||
static unsigned int is_jumbo_frm(int len, int enh_desc)
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
|
||||
|
@ -112,7 +109,7 @@ static unsigned int stmmac_is_jumbo_frm(int len, int enh_desc)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
static void refill_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
{
|
||||
struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
|
||||
|
||||
|
@ -122,12 +119,12 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
|
|||
}
|
||||
|
||||
/* In ring mode we need to fill the desc3 because it is used as buffer */
|
||||
static void stmmac_init_desc3(struct dma_desc *p)
|
||||
static void init_desc3(struct dma_desc *p)
|
||||
{
|
||||
p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB);
|
||||
}
|
||||
|
||||
static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
static void clean_desc3(void *priv_ptr, struct dma_desc *p)
|
||||
{
|
||||
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;
|
||||
struct stmmac_priv *priv = tx_q->priv_data;
|
||||
|
@ -140,7 +137,7 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
|
|||
p->des3 = 0;
|
||||
}
|
||||
|
||||
static int stmmac_set_16kib_bfsize(int mtu)
|
||||
static int set_16kib_bfsize(int mtu)
|
||||
{
|
||||
int ret = 0;
|
||||
if (unlikely(mtu >= BUF_SIZE_8KiB))
|
||||
|
@ -149,10 +146,10 @@ static int stmmac_set_16kib_bfsize(int mtu)
|
|||
}
|
||||
|
||||
const struct stmmac_mode_ops ring_mode_ops = {
|
||||
.is_jumbo_frm = stmmac_is_jumbo_frm,
|
||||
.jumbo_frm = stmmac_jumbo_frm,
|
||||
.refill_desc3 = stmmac_refill_desc3,
|
||||
.init_desc3 = stmmac_init_desc3,
|
||||
.clean_desc3 = stmmac_clean_desc3,
|
||||
.set_16kib_bfsize = stmmac_set_16kib_bfsize,
|
||||
.is_jumbo_frm = is_jumbo_frm,
|
||||
.jumbo_frm = jumbo_frm,
|
||||
.refill_desc3 = refill_desc3,
|
||||
.init_desc3 = init_desc3,
|
||||
.clean_desc3 = clean_desc3,
|
||||
.set_16kib_bfsize = set_16kib_bfsize,
|
||||
};
|
||||
|
|
|
@ -291,11 +291,9 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,
|
|||
cmd->base.speed = priv->xstats.pcs_speed;
|
||||
|
||||
/* Get and convert ADV/LP_ADV from the HW AN registers */
|
||||
if (!priv->hw->mac->pcs_get_adv_lp)
|
||||
if (stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv))
|
||||
return -EOPNOTSUPP; /* should never happen indeed */
|
||||
|
||||
priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv);
|
||||
|
||||
/* Encoding of PSE bits is defined in 802.3z, 37.2.1.4 */
|
||||
|
||||
ethtool_convert_link_mode_to_legacy_u32(
|
||||
|
@ -393,11 +391,7 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
|
|||
ADVERTISED_10baseT_Full);
|
||||
|
||||
spin_lock(&priv->lock);
|
||||
|
||||
if (priv->hw->mac->pcs_ctrl_ane)
|
||||
priv->hw->mac->pcs_ctrl_ane(priv->ioaddr, 1,
|
||||
priv->hw->ps, 0);
|
||||
|
||||
stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, priv->hw->ps, 0);
|
||||
spin_unlock(&priv->lock);
|
||||
|
||||
return 0;
|
||||
|
@ -442,8 +436,8 @@ static void stmmac_ethtool_gregs(struct net_device *dev,
|
|||
|
||||
memset(reg_space, 0x0, REG_SPACE_SIZE);
|
||||
|
||||
priv->hw->mac->dump_regs(priv->hw, reg_space);
|
||||
priv->hw->dma->dump_regs(priv->ioaddr, reg_space);
|
||||
stmmac_dump_mac_regs(priv, priv->hw, reg_space);
|
||||
stmmac_dump_dma_regs(priv, priv->ioaddr, reg_space);
|
||||
/* Copy DMA registers to where ethtool expects them */
|
||||
memcpy(®_space[ETHTOOL_DMA_OFFSET], ®_space[DMA_BUS_MODE / 4],
|
||||
NUM_DWMAC1000_DMA_REGS * 4);
|
||||
|
@ -454,15 +448,13 @@ stmmac_get_pauseparam(struct net_device *netdev,
|
|||
struct ethtool_pauseparam *pause)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(netdev);
|
||||
struct rgmii_adv adv_lp;
|
||||
|
||||
pause->rx_pause = 0;
|
||||
pause->tx_pause = 0;
|
||||
|
||||
if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) {
|
||||
struct rgmii_adv adv_lp;
|
||||
|
||||
if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) {
|
||||
pause->autoneg = 1;
|
||||
priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv_lp);
|
||||
if (!adv_lp.pause)
|
||||
return;
|
||||
} else {
|
||||
|
@ -488,12 +480,10 @@ stmmac_set_pauseparam(struct net_device *netdev,
|
|||
u32 tx_cnt = priv->plat->tx_queues_to_use;
|
||||
struct phy_device *phy = netdev->phydev;
|
||||
int new_pause = FLOW_OFF;
|
||||
struct rgmii_adv adv_lp;
|
||||
|
||||
if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) {
|
||||
struct rgmii_adv adv_lp;
|
||||
|
||||
if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) {
|
||||
pause->autoneg = 1;
|
||||
priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv_lp);
|
||||
if (!adv_lp.pause)
|
||||
return -EOPNOTSUPP;
|
||||
} else {
|
||||
|
@ -515,37 +505,32 @@ stmmac_set_pauseparam(struct net_device *netdev,
|
|||
return phy_start_aneg(phy);
|
||||
}
|
||||
|
||||
priv->hw->mac->flow_ctrl(priv->hw, phy->duplex, priv->flow_ctrl,
|
||||
priv->pause, tx_cnt);
|
||||
stmmac_flow_ctrl(priv, priv->hw, phy->duplex, priv->flow_ctrl,
|
||||
priv->pause, tx_cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void stmmac_get_ethtool_stats(struct net_device *dev,
|
||||
struct ethtool_stats *dummy, u64 *data)
|
||||
{
|
||||
const char *(*dump)(struct stmmac_safety_stats *stats, int index,
|
||||
unsigned long *count);
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
u32 rx_queues_count = priv->plat->rx_queues_to_use;
|
||||
u32 tx_queues_count = priv->plat->tx_queues_to_use;
|
||||
unsigned long count;
|
||||
int i, j = 0;
|
||||
|
||||
if (priv->dma_cap.asp && priv->hw->mac->safety_feat_dump) {
|
||||
dump = priv->hw->mac->safety_feat_dump;
|
||||
int i, j = 0, ret;
|
||||
|
||||
if (priv->dma_cap.asp) {
|
||||
for (i = 0; i < STMMAC_SAFETY_FEAT_SIZE; i++) {
|
||||
if (dump(&priv->sstats, i, &count))
|
||||
if (!stmmac_safety_feat_dump(priv, &priv->sstats, i,
|
||||
&count, NULL))
|
||||
data[j++] = count;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the DMA HW counters for dwmac10/100 */
|
||||
if (priv->hw->dma->dma_diagnostic_fr)
|
||||
priv->hw->dma->dma_diagnostic_fr(&dev->stats,
|
||||
(void *) &priv->xstats,
|
||||
priv->ioaddr);
|
||||
else {
|
||||
ret = stmmac_dma_diagnostic_fr(priv, &dev->stats, (void *) &priv->xstats,
|
||||
priv->ioaddr);
|
||||
if (ret) {
|
||||
/* If supported, for new GMAC chips expose the MMC counters */
|
||||
if (priv->dma_cap.rmon) {
|
||||
dwmac_mmc_read(priv->mmcaddr, &priv->mmc);
|
||||
|
@ -565,11 +550,10 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
|
|||
priv->xstats.phy_eee_wakeup_error_n = val;
|
||||
}
|
||||
|
||||
if ((priv->hw->mac->debug) &&
|
||||
(priv->synopsys_id >= DWMAC_CORE_3_50))
|
||||
priv->hw->mac->debug(priv->ioaddr,
|
||||
(void *)&priv->xstats,
|
||||
rx_queues_count, tx_queues_count);
|
||||
if (priv->synopsys_id >= DWMAC_CORE_3_50)
|
||||
stmmac_mac_debug(priv, priv->ioaddr,
|
||||
(void *)&priv->xstats,
|
||||
rx_queues_count, tx_queues_count);
|
||||
}
|
||||
for (i = 0; i < STMMAC_STATS_LEN; i++) {
|
||||
char *p = (char *)priv + stmmac_gstrings_stats[i].stat_offset;
|
||||
|
@ -581,8 +565,6 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
|
|||
static int stmmac_get_sset_count(struct net_device *netdev, int sset)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(netdev);
|
||||
const char *(*dump)(struct stmmac_safety_stats *stats, int index,
|
||||
unsigned long *count);
|
||||
int i, len, safety_len = 0;
|
||||
|
||||
switch (sset) {
|
||||
|
@ -591,11 +573,11 @@ static int stmmac_get_sset_count(struct net_device *netdev, int sset)
|
|||
|
||||
if (priv->dma_cap.rmon)
|
||||
len += STMMAC_MMC_STATS_LEN;
|
||||
if (priv->dma_cap.asp && priv->hw->mac->safety_feat_dump) {
|
||||
dump = priv->hw->mac->safety_feat_dump;
|
||||
|
||||
if (priv->dma_cap.asp) {
|
||||
for (i = 0; i < STMMAC_SAFETY_FEAT_SIZE; i++) {
|
||||
if (dump(&priv->sstats, i, NULL))
|
||||
if (!stmmac_safety_feat_dump(priv,
|
||||
&priv->sstats, i,
|
||||
NULL, NULL))
|
||||
safety_len++;
|
||||
}
|
||||
|
||||
|
@ -613,17 +595,15 @@ static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data)
|
|||
int i;
|
||||
u8 *p = data;
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
const char *(*dump)(struct stmmac_safety_stats *stats, int index,
|
||||
unsigned long *count);
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
if (priv->dma_cap.asp && priv->hw->mac->safety_feat_dump) {
|
||||
dump = priv->hw->mac->safety_feat_dump;
|
||||
if (priv->dma_cap.asp) {
|
||||
for (i = 0; i < STMMAC_SAFETY_FEAT_SIZE; i++) {
|
||||
const char *desc = dump(&priv->sstats, i, NULL);
|
||||
|
||||
if (desc) {
|
||||
const char *desc;
|
||||
if (!stmmac_safety_feat_dump(priv,
|
||||
&priv->sstats, i,
|
||||
NULL, &desc)) {
|
||||
memcpy(p, desc, ETH_GSTRING_LEN);
|
||||
p += ETH_GSTRING_LEN;
|
||||
}
|
||||
|
@ -810,7 +790,7 @@ static int stmmac_set_coalesce(struct net_device *dev,
|
|||
priv->tx_coal_frames = ec->tx_max_coalesced_frames;
|
||||
priv->tx_coal_timer = ec->tx_coalesce_usecs;
|
||||
priv->rx_riwt = rx_riwt;
|
||||
priv->hw->dma->rx_watchdog(priv->ioaddr, priv->rx_riwt, rx_cnt);
|
||||
stmmac_rx_watchdog(priv, priv->ioaddr, priv->rx_riwt, rx_cnt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
#include "common.h"
|
||||
#include "stmmac_ptp.h"
|
||||
|
||||
static void stmmac_config_hw_tstamping(void __iomem *ioaddr, u32 data)
|
||||
static void config_hw_tstamping(void __iomem *ioaddr, u32 data)
|
||||
{
|
||||
writel(data, ioaddr + PTP_TCR);
|
||||
}
|
||||
|
||||
static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
|
||||
u32 ptp_clock, int gmac4)
|
||||
static void config_sub_second_increment(void __iomem *ioaddr,
|
||||
u32 ptp_clock, int gmac4, u32 *ssinc)
|
||||
{
|
||||
u32 value = readl(ioaddr + PTP_TCR);
|
||||
unsigned long data;
|
||||
|
@ -57,10 +57,11 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
|
|||
|
||||
writel(reg_value, ioaddr + PTP_SSIR);
|
||||
|
||||
return data;
|
||||
if (ssinc)
|
||||
*ssinc = data;
|
||||
}
|
||||
|
||||
static int stmmac_init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
|
||||
static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
|
||||
{
|
||||
int limit;
|
||||
u32 value;
|
||||
|
@ -85,7 +86,7 @@ static int stmmac_init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int stmmac_config_addend(void __iomem *ioaddr, u32 addend)
|
||||
static int config_addend(void __iomem *ioaddr, u32 addend)
|
||||
{
|
||||
u32 value;
|
||||
int limit;
|
||||
|
@ -109,8 +110,8 @@ static int stmmac_config_addend(void __iomem *ioaddr, u32 addend)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
|
||||
int add_sub, int gmac4)
|
||||
static int adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
|
||||
int add_sub, int gmac4)
|
||||
{
|
||||
u32 value;
|
||||
int limit;
|
||||
|
@ -152,7 +153,7 @@ static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static u64 stmmac_get_systime(void __iomem *ioaddr)
|
||||
static void get_systime(void __iomem *ioaddr, u64 *systime)
|
||||
{
|
||||
u64 ns;
|
||||
|
||||
|
@ -161,14 +162,15 @@ static u64 stmmac_get_systime(void __iomem *ioaddr)
|
|||
/* Get the TSS and convert sec time value to nanosecond */
|
||||
ns += readl(ioaddr + PTP_STSR) * 1000000000ULL;
|
||||
|
||||
return ns;
|
||||
if (systime)
|
||||
*systime = ns;
|
||||
}
|
||||
|
||||
const struct stmmac_hwtimestamp stmmac_ptp = {
|
||||
.config_hw_tstamping = stmmac_config_hw_tstamping,
|
||||
.init_systime = stmmac_init_systime,
|
||||
.config_sub_second_increment = stmmac_config_sub_second_increment,
|
||||
.config_addend = stmmac_config_addend,
|
||||
.adjust_systime = stmmac_adjust_systime,
|
||||
.get_systime = stmmac_get_systime,
|
||||
.config_hw_tstamping = config_hw_tstamping,
|
||||
.init_systime = init_systime,
|
||||
.config_sub_second_increment = config_sub_second_increment,
|
||||
.config_addend = config_addend,
|
||||
.adjust_systime = adjust_systime,
|
||||
.get_systime = get_systime,
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -49,9 +49,7 @@ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, s32 ppb)
|
|||
addend = neg_adj ? (addend - diff) : (addend + diff);
|
||||
|
||||
spin_lock_irqsave(&priv->ptp_lock, flags);
|
||||
|
||||
priv->hw->ptp->config_addend(priv->ptpaddr, addend);
|
||||
|
||||
stmmac_config_addend(priv, priv->ptpaddr, addend);
|
||||
spin_unlock_irqrestore(&priv->ptp_lock, flags);
|
||||
|
||||
return 0;
|
||||
|
@ -84,10 +82,8 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
|
|||
nsec = reminder;
|
||||
|
||||
spin_lock_irqsave(&priv->ptp_lock, flags);
|
||||
|
||||
priv->hw->ptp->adjust_systime(priv->ptpaddr, sec, nsec, neg_adj,
|
||||
priv->plat->has_gmac4);
|
||||
|
||||
stmmac_adjust_systime(priv, priv->ptpaddr, sec, nsec, neg_adj,
|
||||
priv->plat->has_gmac4);
|
||||
spin_unlock_irqrestore(&priv->ptp_lock, flags);
|
||||
|
||||
return 0;
|
||||
|
@ -110,9 +106,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
|||
u64 ns;
|
||||
|
||||
spin_lock_irqsave(&priv->ptp_lock, flags);
|
||||
|
||||
ns = priv->hw->ptp->get_systime(priv->ptpaddr);
|
||||
|
||||
stmmac_get_systime(priv, priv->ptpaddr, &ns);
|
||||
spin_unlock_irqrestore(&priv->ptp_lock, flags);
|
||||
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
@ -137,9 +131,7 @@ static int stmmac_set_time(struct ptp_clock_info *ptp,
|
|||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&priv->ptp_lock, flags);
|
||||
|
||||
priv->hw->ptp->init_systime(priv->ptpaddr, ts->tv_sec, ts->tv_nsec);
|
||||
|
||||
stmmac_init_systime(priv, priv->ptpaddr, ts->tv_sec, ts->tv_nsec);
|
||||
spin_unlock_irqrestore(&priv->ptp_lock, flags);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue