diff options
author | Madalin Bucur <madalin.bucur@freescale.com> | 2013-05-22 14:13:57 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-07-15 21:45:05 (GMT) |
commit | 77ccf8c1fca27a057038fe824894b18d42a78424 (patch) | |
tree | 19f51e35222ed315266ae52f0b85f720e0fbd6de /drivers/net/ethernet/freescale/fman | |
parent | 143100f5107ed794e7b9ece229031998905f586f (diff) | |
download | linux-fsl-qoriq-77ccf8c1fca27a057038fe824894b18d42a78424.tar.xz |
dpaa_eth/fmd: move NetCommSw calls wrapping code to the FMD wrapper
Several functions wrapping NetCommSw calls are moved from the
dpa_eth driver code to the FMD Linux wrapper files.
Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
Change-Id: I68808913bb8072888980c818fa3c1078ead780b0
Reviewed-on: http://git.am.freescale.net:8181/3072
Reviewed-by: Hamciuc Bogdan-BHAMCIU1 <bogdan.hamciuc@freescale.com>
Reviewed-by: Sovaiala Cristian-Constantin-B39531 <Cristian.Sovaiala@freescale.com>
Reviewed-by: Radulescu Ruxandra Ioana-B05472 <ruxandra.radulescu@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/fman')
-rw-r--r-- | drivers/net/ethernet/freescale/fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 93 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c | 456 |
2 files changed, 546 insertions, 3 deletions
diff --git a/drivers/net/ethernet/freescale/fman/src/inc/wrapper/lnxwrp_fsl_fman.h b/drivers/net/ethernet/freescale/fman/src/inc/wrapper/lnxwrp_fsl_fman.h index 8adf489..f182e3f 100644 --- a/drivers/net/ethernet/freescale/fman/src/inc/wrapper/lnxwrp_fsl_fman.h +++ b/drivers/net/ethernet/freescale/fman/src/inc/wrapper/lnxwrp_fsl_fman.h @@ -44,6 +44,8 @@ #include <linux/fsl_qman.h> /* struct qman_fq */ #include "dpaa_integration_ext.h" #include "fm_port_ext.h" +#include "fm_mac_ext.h" +#include "fm_rtc_ext.h" /**************************************************************************//** @Group FM_LnxKern_grp Frame Manager Linux wrapper API @@ -67,11 +69,16 @@ /*****************************************************************************/ /**************************************************************************//** - @Description A structure .., + @Description FM device opaque structure used for type checking *//***************************************************************************/ struct fm; /**************************************************************************//** + @Description FM MAC device opaque structure used for type checking +*//***************************************************************************/ +struct fm_mac_dev; + +/**************************************************************************//** @Description A structure .., *//***************************************************************************/ struct fm_port; @@ -273,7 +280,10 @@ int fm_port_enable(struct fm_port *port); *//***************************************************************************/ void fm_port_disable(struct fm_port *port); -void *fm_port_get_handle(struct fm_port *port); +void *fm_port_get_handle(const struct fm_port *port); + +u64 *fm_port_get_buffer_time_stamp(const struct fm_port *port, + const void *data); /**************************************************************************//** @Function fm_port_get_base_address @@ -340,6 +350,85 @@ int fm_port_set_rate_limit(struct fm_port *port, *//***************************************************************************/ int fm_port_del_rate_limit(struct fm_port *port); +/**************************************************************************//** +@Function fm_mac_set_exception + +@Description Set MAC exception state. + +@Param[in] fm_mac_dev - A handle of the FM MAC device. +@Param[in] exception - FM MAC exception type. +@Param[in] enable - new state. + +*//***************************************************************************/ +int fm_mac_set_exception(struct fm_mac_dev *fm_mac_dev, + e_FmMacExceptions exception, bool enable); + +int fm_mac_free(struct fm_mac_dev *fm_mac_dev); + +struct fm_mac_dev *fm_mac_config(t_FmMacParams *params); + +int fm_mac_config_max_frame_length(struct fm_mac_dev *fm_mac_dev, + int len); + +int fm_mac_config_pad_and_crc(struct fm_mac_dev *fm_mac_dev, bool enable); + +int fm_mac_config_half_duplex(struct fm_mac_dev *fm_mac_dev, bool enable); + +int fm_mac_config_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable); + +int fm_mac_init(struct fm_mac_dev *fm_mac_dev); + +int fm_mac_get_version(struct fm_mac_dev *fm_mac_dev, uint32_t *version); + +int fm_mac_enable(struct fm_mac_dev *fm_mac_dev); + +int fm_mac_disable(struct fm_mac_dev *fm_mac_dev); + +int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev, + bool enable); + +int fm_mac_remove_hash_mac_addr(struct fm_mac_dev *fm_mac_dev, + t_EnetAddr *mac_addr); + +int fm_mac_add_hash_mac_addr(struct fm_mac_dev *fm_mac_dev, + t_EnetAddr *mac_addr); + +int fm_mac_modify_mac_addr(struct fm_mac_dev *fm_mac_dev, + uint8_t *addr); + +int fm_mac_adjust_link(struct fm_mac_dev *fm_mac_dev, + bool link, int speed, bool duplex); + +int fm_mac_enable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev); + +int fm_mac_disable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev); + +int fm_mac_set_rx_ignore_pause_frames( + struct fm_mac_dev *fm_mac_dev, bool en); + +int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev, + bool en); + +int fm_rtc_enable(struct fm *fm_dev); + +int fm_rtc_disable(struct fm *fm_dev); + +int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts); + +int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts); + +int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift); + +int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift); + +int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id, + uint64_t time); + +int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id, + uint64_t fiper); + +void fm_mac_dump_regs(struct fm_mac_dev *fm_mac_dev); + /** @} */ /* end of FM_LnxKern_ctrl_grp group */ /** @} */ /* end of FM_LnxKern_grp group */ diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c index eadb36f..e48fbcd 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.c @@ -108,6 +108,11 @@ extern struct device_node *GetFmPortAdvArgsDevTreeNode (struct device_node *fm_n /* Maximum value for the fsl_fm_rx_extra_headroom bootarg */ #define FSL_FM_RX_EXTRA_HEADROOM_MAX 384 +#define TX_PAUSE_PRIO_DEFAULT 0xff +#define TX_PAUSE_TIME_ENABLE 0xf000 +#define TX_PAUSE_TIME_DISABLE 0 +#define TX_PAUSE_THRESH_DEFAULT 0 + /* * Max frame size, across all interfaces. * Configurable from Kconfig or bootargs, to avoid allocating @@ -1186,7 +1191,7 @@ void fm_port_unbind(struct fm_port *port) } EXPORT_SYMBOL(fm_port_unbind); -void * fm_port_get_handle(struct fm_port *port) +void *fm_port_get_handle(const struct fm_port *port) { t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev*)port; @@ -1194,6 +1199,14 @@ void * fm_port_get_handle(struct fm_port *port) } EXPORT_SYMBOL(fm_port_get_handle); +u64 *fm_port_get_buffer_time_stamp(const struct fm_port *port, + const void *data) +{ + return FM_PORT_GetBufferTimeStamp(fm_port_get_handle(port), + (void *)data); +} +EXPORT_SYMBOL(fm_port_get_buffer_time_stamp); + void fm_port_get_base_addr(const struct fm_port *port, uint64_t *base_addr) { t_LnxWrpFmPortDev *p_LnxWrpFmPortDev = (t_LnxWrpFmPortDev *)port; @@ -1298,6 +1311,447 @@ int fm_port_del_rate_limit(struct fm_port *port) } EXPORT_SYMBOL(fm_port_del_rate_limit); +int fm_mac_set_exception(struct fm_mac_dev *fm_mac_dev, + e_FmMacExceptions exception, bool enable) +{ + int err; + int _errno; + + err = FM_MAC_SetException(fm_mac_dev, exception, enable); + + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_SetException() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_set_exception); + +int fm_mac_free(struct fm_mac_dev *fm_mac_dev) +{ + int err; + int _error; + + err = FM_MAC_Free(fm_mac_dev); + _error = -GET_ERROR_TYPE(err); + + if (unlikely(_error < 0)) + pr_err("FM_MAC_Free() = 0x%08x\n", err); + + return _error; +} +EXPORT_SYMBOL(fm_mac_free); + +struct fm_mac_dev *fm_mac_config(t_FmMacParams *params) +{ + struct fm_mac_dev *fm_mac_dev; + + fm_mac_dev = FM_MAC_Config(params); + if (unlikely(fm_mac_dev == NULL)) + pr_err("FM_MAC_Config() failed\n"); + + return fm_mac_dev; +} +EXPORT_SYMBOL(fm_mac_config); + +int fm_mac_config_max_frame_length(struct fm_mac_dev *fm_mac_dev, + int len) +{ + int err; + int _errno; + + err = FM_MAC_ConfigMaxFrameLength(fm_mac_dev, len); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_ConfigMaxFrameLength() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_config_max_frame_length); + +int fm_mac_config_pad_and_crc(struct fm_mac_dev *fm_mac_dev, bool enable) +{ + int err; + int _errno; + + err = FM_MAC_ConfigPadAndCrc(fm_mac_dev, enable); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_ConfigPadAndCrc() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_config_pad_and_crc); + +int fm_mac_config_half_duplex(struct fm_mac_dev *fm_mac_dev, bool enable) +{ + int err; + int _errno; + + err = FM_MAC_ConfigHalfDuplex(fm_mac_dev, enable); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_ConfigHalfDuplex() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_config_half_duplex); + +int fm_mac_config_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable) +{ + int err; + int _errno; + + err = FM_MAC_ConfigResetOnInit(fm_mac_dev, enable); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_ConfigResetOnInit() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_config_reset_on_init); + +int fm_mac_init(struct fm_mac_dev *fm_mac_dev) +{ + int err; + int _errno; + + err = FM_MAC_Init(fm_mac_dev); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_Init() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_init); + +int fm_mac_get_version(struct fm_mac_dev *fm_mac_dev, uint32_t *version) +{ + int err; + int _errno; + + err = FM_MAC_GetVesrion(fm_mac_dev, version); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_GetVesrion() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_get_version); + +int fm_mac_enable(struct fm_mac_dev *fm_mac_dev) +{ + int _errno; + t_Error err; + + err = FM_MAC_Enable(fm_mac_dev, e_COMM_MODE_RX_AND_TX); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_Enable() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_enable); + +int fm_mac_disable(struct fm_mac_dev *fm_mac_dev) +{ + int _errno; + t_Error err; + + err = FM_MAC_Disable(fm_mac_dev, e_COMM_MODE_RX_AND_TX); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_Disable() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_disable); + +int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev, + bool enable) +{ + int _errno; + t_Error err; + + err = FM_MAC_SetPromiscuous(fm_mac_dev, enable); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_SetPromiscuous() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_set_promiscuous); + +int fm_mac_remove_hash_mac_addr(struct fm_mac_dev *fm_mac_dev, + t_EnetAddr *mac_addr) +{ + int _errno; + t_Error err; + + err = FM_MAC_RemoveHashMacAddr(fm_mac_dev, mac_addr); + _errno = -GET_ERROR_TYPE(err); + if (_errno < 0) { + pr_err("FM_MAC_RemoveHashMacAddr() = 0x%08x\n", err); + return _errno; + } + + return 0; +} +EXPORT_SYMBOL(fm_mac_remove_hash_mac_addr); + +int fm_mac_add_hash_mac_addr(struct fm_mac_dev *fm_mac_dev, + t_EnetAddr *mac_addr) +{ + int _errno; + t_Error err; + + err = FM_MAC_AddHashMacAddr(fm_mac_dev, mac_addr); + _errno = -GET_ERROR_TYPE(err); + if (_errno < 0) { + pr_err("FM_MAC_AddHashMacAddr() = 0x%08x\n", err); + return _errno; + } + + return 0; +} +EXPORT_SYMBOL(fm_mac_add_hash_mac_addr); + +int fm_mac_modify_mac_addr(struct fm_mac_dev *fm_mac_dev, + uint8_t *addr) +{ + int _errno; + t_Error err; + + err = FM_MAC_ModifyMacAddr(fm_mac_dev, (t_EnetAddr *)addr); + _errno = -GET_ERROR_TYPE(err); + if (_errno < 0) + pr_err("FM_MAC_ModifyMacAddr() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_modify_mac_addr); + +int fm_mac_adjust_link(struct fm_mac_dev *fm_mac_dev, + bool link, int speed, bool duplex) +{ + int _errno; + t_Error err; + + if (!link) { +#if (DPAA_VERSION < 11) + FM_MAC_RestartAutoneg(fm_mac_dev); +#endif + return 0; + } + + err = FM_MAC_AdjustLink(fm_mac_dev, speed, duplex); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_AdjustLink() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_adjust_link); + +int fm_mac_enable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev) +{ + int _errno; + t_Error err; + + err = FM_MAC_Enable1588TimeStamp(fm_mac_dev); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_Enable1588TimeStamp() = 0x%08x\n", err); + return _errno; +} +EXPORT_SYMBOL(fm_mac_enable_1588_time_stamp); + +int fm_mac_disable_1588_time_stamp(struct fm_mac_dev *fm_mac_dev) +{ + int _errno; + t_Error err; + + err = FM_MAC_Disable1588TimeStamp(fm_mac_dev); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_MAC_Disable1588TimeStamp() = 0x%08x\n", err); + return _errno; +} +EXPORT_SYMBOL(fm_mac_disable_1588_time_stamp); + +int fm_mac_set_rx_ignore_pause_frames( + struct fm_mac_dev *fm_mac_dev, bool en) +{ + int _errno; + t_Error err; + + /* if rx pause is enabled, do NOT ignore pause frames */ + err = FM_MAC_SetRxIgnorePauseFrames(fm_mac_dev, !en); + + _errno = -GET_ERROR_TYPE(err); + if (_errno < 0) + pr_err("FM_MAC_SetRxIgnorePauseFrames() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_set_rx_ignore_pause_frames); + +int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev, + bool en) +{ + int _errno; + t_Error err; + + if (en) + err = FM_MAC_SetTxPauseFrames(fm_mac_dev, + TX_PAUSE_PRIO_DEFAULT, + TX_PAUSE_TIME_ENABLE, + TX_PAUSE_THRESH_DEFAULT); + else + err = FM_MAC_SetTxPauseFrames(fm_mac_dev, + TX_PAUSE_PRIO_DEFAULT, + TX_PAUSE_TIME_DISABLE, + TX_PAUSE_THRESH_DEFAULT); + + _errno = -GET_ERROR_TYPE(err); + if (_errno < 0) + pr_err("FM_MAC_SetTxPauseFrames() = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_mac_set_tx_pause_frames); + +int fm_rtc_enable(struct fm *fm_dev) +{ + int _errno; + t_Error err; + + err = FM_RTC_Enable(fm_get_rtc_handle(fm_dev), 0); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_Enable = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_enable); + +int fm_rtc_disable(struct fm *fm_dev) +{ + int _errno; + t_Error err; + + err = FM_RTC_Disable(fm_get_rtc_handle(fm_dev)); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_Disable = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_disable); + +int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts) +{ + int _errno; + t_Error err; + + err = FM_RTC_GetCurrentTime(fm_get_rtc_handle(fm_dev), ts); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_GetCurrentTime = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_get_cnt); + +int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts) +{ + int _errno; + t_Error err; + + err = FM_RTC_SetCurrentTime(fm_get_rtc_handle(fm_dev), ts); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_SetCurrentTime = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_set_cnt); + +int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift) +{ + int _errno; + t_Error err; + + err = FM_RTC_GetFreqCompensation(fm_get_rtc_handle(fm_dev), + drift); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_GetFreqCompensation = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_get_drift); + +int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift) +{ + int _errno; + t_Error err; + + err = FM_RTC_SetFreqCompensation(fm_get_rtc_handle(fm_dev), + drift); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_SetFreqCompensation = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_set_drift); + +int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id, + uint64_t time) +{ + t_FmRtcAlarmParams alarm; + int _errno; + t_Error err; + + alarm.alarmId = id; + alarm.alarmTime = time; + alarm.f_AlarmCallback = NULL; + err = FM_RTC_SetAlarm(fm_get_rtc_handle(fm_dev), + &alarm); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_SetAlarm = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_set_alarm); + +int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id, + uint64_t fiper) +{ + t_FmRtcPeriodicPulseParams pp; + int _errno; + t_Error err; + + pp.periodicPulseId = id; + pp.periodicPulsePeriod = fiper; + pp.f_PeriodicPulseCallback = NULL; + err = FM_RTC_SetPeriodicPulse(fm_get_rtc_handle(fm_dev), &pp); + _errno = -GET_ERROR_TYPE(err); + if (unlikely(_errno < 0)) + pr_err("FM_RTC_SetPeriodicPulse = 0x%08x\n", err); + + return _errno; +} +EXPORT_SYMBOL(fm_rtc_set_fiper); + +void fm_mac_dump_regs(struct fm_mac_dev *fm_mac_dev) +{ + FM_MAC_DumpRegs(fm_mac_dev); +} +EXPORT_SYMBOL(fm_mac_dump_regs); + void fm_mutex_lock(void) { mutex_lock(&lnxwrp_mutex); |