Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/HARMONIZED_LINUX_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.17
6.18
2 changes: 1 addition & 1 deletion config/PROGRAM_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0
1.12.0
10 changes: 6 additions & 4 deletions src/kernel/drivers/net/can/dev/calc_bittiming.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,

void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
const struct can_bittiming *dbt,
u32 *ctrlmode, u32 ctrlmode_supported)
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported)

{
if (!tdc_const || !(ctrlmode_supported & CAN_CTRLMODE_TDC_AUTO))
u32 tdc_auto = tdc_mask & CAN_CTRLMODE_TDC_AUTO_MASK;

if (!tdc_const || !(ctrlmode_supported & tdc_auto))
return;

*ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
*ctrlmode &= ~tdc_mask;

/* As specified in ISO 11898-1 section 11.3.3 "Transmitter
* delay compensation" (TDC) is only applicable if data BRP is
Expand All @@ -240,6 +242,6 @@ void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
if (sample_point_in_tc < tdc_const->tdco_min)
return;
tdc->tdco = min(sample_point_in_tc, tdc_const->tdco_max);
*ctrlmode |= CAN_CTRLMODE_TDC_AUTO;
*ctrlmode |= tdc_auto;
}
}
74 changes: 71 additions & 3 deletions src/kernel/drivers/net/can/dev/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,39 @@ const char *can_get_state_str(const enum can_state state)
}
EXPORT_SYMBOL_GPL(can_get_state_str);

const char *can_get_ctrlmode_str(u32 ctrlmode)
{
switch (ctrlmode & ~(ctrlmode - 1)) {
case 0:
return "none";
case CAN_CTRLMODE_LOOPBACK:
return "loopback";
case CAN_CTRLMODE_LISTENONLY:
return "listen-only";
case CAN_CTRLMODE_3_SAMPLES:
return "triple-sampling";
case CAN_CTRLMODE_ONE_SHOT:
return "one-shot";
case CAN_CTRLMODE_BERR_REPORTING:
return "berr-reporting";
case CAN_CTRLMODE_FD:
return "fd";
case CAN_CTRLMODE_PRESUME_ACK:
return "presume-ack";
case CAN_CTRLMODE_FD_NON_ISO:
return "fd-non-iso";
case CAN_CTRLMODE_CC_LEN8_DLC:
return "cc-len8-dlc";
case CAN_CTRLMODE_TDC_AUTO:
return "fd-tdc-auto";
case CAN_CTRLMODE_TDC_MANUAL:
return "fd-tdc-manual";
default:
return "<unknown>";
}
}
EXPORT_SYMBOL_GPL(can_get_ctrlmode_str);

static enum can_state can_state_err_to_state(u16 err)
{
if (err < CAN_ERROR_WARNING_THRESHOLD)
Expand Down Expand Up @@ -336,6 +369,21 @@ void free_candev(struct net_device *dev)
}
EXPORT_SYMBOL_GPL(free_candev);

void can_set_default_mtu(struct net_device *dev)
{
struct can_priv *priv = netdev_priv(dev);

if (priv->ctrlmode & CAN_CTRLMODE_FD) {
dev->mtu = CANFD_MTU;
dev->min_mtu = CANFD_MTU;
dev->max_mtu = CANFD_MTU;
} else {
dev->mtu = CAN_MTU;
dev->min_mtu = CAN_MTU;
dev->max_mtu = CAN_MTU;
}
}

/* changing MTU and control mode for CAN/CANFD devices */
int can_change_mtu(struct net_device *dev, int new_mtu)
{
Expand Down Expand Up @@ -374,6 +422,26 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
}
EXPORT_SYMBOL_GPL(can_change_mtu);

/* helper to define static CAN controller features at device creation time */
int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
{
struct can_priv *priv = netdev_priv(dev);

/* alloc_candev() succeeded => netdev_priv() is valid at this point */
if (priv->ctrlmode_supported & static_mode) {
netdev_warn(dev,
"Controller features can not be supported and static at the same time\n");
return -EINVAL;
}
priv->ctrlmode = static_mode;

/* override MTU which was set by default in can_setup()? */
can_set_default_mtu(dev);

return 0;
}
EXPORT_SYMBOL_GPL(can_set_static_ctrlmode);

/* Common open function when the device gets opened.
*
* This function should be called in the open function of the device
Expand All @@ -390,8 +458,8 @@ int open_candev(struct net_device *dev)

/* For CAN FD the data bitrate has to be >= the arbitration bitrate */
if ((priv->ctrlmode & CAN_CTRLMODE_FD) &&
(!priv->data_bittiming.bitrate ||
priv->data_bittiming.bitrate < priv->bittiming.bitrate)) {
(!priv->fd.data_bittiming.bitrate ||
priv->fd.data_bittiming.bitrate < priv->bittiming.bitrate)) {
netdev_err(dev, "incorrect/missing data bit-timing\n");
return -EINVAL;
}
Expand Down Expand Up @@ -450,7 +518,7 @@ int register_candev(struct net_device *dev)
if (!priv->bitrate_const != !priv->bitrate_const_cnt)
return -EINVAL;

if (!priv->data_bitrate_const != !priv->data_bitrate_const_cnt)
if (!priv->fd.data_bitrate_const != !priv->fd.data_bitrate_const_cnt)
return -EINVAL;

dev->resmgr_ops = &can_link_ops;
Expand Down
24 changes: 12 additions & 12 deletions src/kernel/drivers/net/can/dev/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ static int can_changelink(struct net_device *dev,
dev->mtu = CANFD_MTU;
} else {
dev->mtu = CAN_MTU;
memset(&priv->data_bittiming, 0,
sizeof(priv->data_bittiming));
memset(&priv->fd.data_bittiming, 0,
sizeof(priv->fd.data_bittiming));
priv->ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
memset(&priv->tdc, 0, sizeof(priv->tdc));
memset(&priv->fd.tdc, 0, sizeof(priv->fd.tdc));
}

tdc_mask = cm->mask & CAN_CTRLMODE_FD_TDC_MASK;
Expand Down Expand Up @@ -166,15 +166,15 @@ static int can_changelink(struct net_device *dev,
* directly via do_set_bitrate(). Bail out if neither
* is given.
*/
if (!priv->data_bittiming_const && !priv->do_set_data_bittiming &&
!priv->data_bitrate_const)
if (!priv->fd.data_bittiming_const && !priv->do_set_data_bittiming &&
!priv->fd.data_bitrate_const)
return -EOPNOTSUPP;

memcpy(&dbt, &user->data_bittiming, sizeof(dbt));
err = can_get_bittiming(dev, &dbt,
priv->data_bittiming_const,
priv->data_bitrate_const,
priv->data_bitrate_const_cnt,
priv->fd.data_bittiming_const,
priv->fd.data_bitrate_const,
priv->fd.data_bitrate_const_cnt,
extack);
if (err)
return err;
Expand All @@ -185,19 +185,19 @@ static int can_changelink(struct net_device *dev,
return -EINVAL;
}

memset(&priv->tdc, 0, sizeof(priv->tdc));
memset(&priv->fd.tdc, 0, sizeof(priv->fd.tdc));
if (user->set_tdc) {
} else if (!tdc_mask) {
/* Neither of TDC parameters nor TDC flags are
* provided: do calculation
*/
can_calc_tdco(&priv->tdc, priv->tdc_const, &priv->data_bittiming,
&priv->ctrlmode, priv->ctrlmode_supported);
can_calc_tdco(&priv->fd.tdc, priv->fd.tdc_const, &dbt,
tdc_mask, &priv->ctrlmode, priv->ctrlmode_supported);
} /* else: both CAN_CTRLMODE_TDC_{AUTO,MANUAL} are explicitly
* turned off. TDC is disabled: do nothing
*/

memcpy(&priv->data_bittiming, &dbt, sizeof(dbt));
memcpy(&priv->fd.data_bittiming, &dbt, sizeof(dbt));

if (priv->do_set_data_bittiming) {
/* Finally, set the bit-timing registers */
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/drivers/net/can/sja1000/sja1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF)
goto out;

while ((isrc = priv->read_reg(priv, SJA1000_IR)) &&
(n < SJA1000_MAX_IRQ)) {
while ((n < SJA1000_MAX_IRQ) &&
(isrc = priv->read_reg(priv, SJA1000_IR))) {

status = priv->read_reg(priv, SJA1000_SR);
/* check for absent controller due to hw unplug */
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/include/asm-generic/bitops/__fls.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* Undefined if no set bit exists, so code should check against 0 first.
*/
static __always_inline unsigned int generic___fls(unsigned long word)
static __always_inline __attribute_const__ unsigned int generic___fls(unsigned long word)
{
unsigned int num = BITS_PER_LONG - 1;

Expand Down
4 changes: 2 additions & 2 deletions src/kernel/include/asm-generic/bitops/fls64.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
* at position 64.
*/
#if BITS_PER_LONG == 32
static __always_inline int fls64(__u64 x)
static __always_inline __attribute_const__ int fls64(__u64 x)
{
__u32 h = x >> 32;
if (h)
return fls(h) + 32;
return fls(x);
}
#elif BITS_PER_LONG == 64
static __always_inline int fls64(__u64 x)
static __always_inline __attribute_const__ int fls64(__u64 x)
{
if (x == 0)
return 0;
Expand Down
48 changes: 46 additions & 2 deletions src/kernel/include/linux/can/bittiming.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

#define CAN_CTRLMODE_FD_TDC_MASK \
(CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)
#define CAN_CTRLMODE_TDC_AUTO_MASK \
(CAN_CTRLMODE_TDC_AUTO)
#define CAN_CTRLMODE_TDC_MANUAL_MASK \
(CAN_CTRLMODE_TDC_MANUAL)

/*
* struct can_tdc - CAN FD Transmission Delay Compensation parameters
Expand Down Expand Up @@ -138,13 +142,24 @@ struct can_tdc_const {
u32 tdcf_max;
};

struct data_bittiming_params {
const struct can_bittiming_const *data_bittiming_const;
struct can_bittiming data_bittiming;
const struct can_tdc_const *tdc_const;
struct can_tdc tdc;
const u32 *data_bitrate_const;
unsigned int data_bitrate_const_cnt;
int (*do_set_data_bittiming)(struct net_device *dev);
int (*do_get_auto_tdcv)(const struct net_device *dev, u32 *tdcv);
};

#ifdef CONFIG_CAN_CALC_BITTIMING
int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
const struct can_bittiming_const *btc, struct netlink_ext_ack *extack);

void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
const struct can_bittiming *dbt,
u32 *ctrlmode, u32 ctrlmode_supported);
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported);
#else /* !CONFIG_CAN_CALC_BITTIMING */
static inline int
can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
Expand All @@ -157,7 +172,7 @@ can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
static inline void
can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
const struct can_bittiming *dbt,
u32 *ctrlmode, u32 ctrlmode_supported)
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported)
{
}
#endif /* CONFIG_CAN_CALC_BITTIMING */
Expand All @@ -173,6 +188,35 @@ int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt,
const unsigned int bitrate_const_cnt,
struct netlink_ext_ack *extack);

/*
* can_get_relative_tdco() - TDCO relative to the sample point
*
* struct can_tdc::tdco represents the absolute offset from TDCV. Some
* controllers use instead an offset relative to the Sample Point (SP)
* such that:
*
* SSP = TDCV + absolute TDCO
* = TDCV + SP + relative TDCO
*
* -+----------- one bit ----------+-- TX pin
* |<--- Sample Point --->|
*
* --+----------- one bit ----------+-- RX pin
* |<-------- TDCV -------->|
* |<------------------------>| absolute TDCO
* |<--- Sample Point --->|
* | |<->| relative TDCO
* |<------------- Secondary Sample Point ------------>|
*/
static inline s32 can_get_relative_tdco(const struct data_bittiming_params *dbt_params)
{
const struct can_bittiming *dbt = &dbt_params->data_bittiming;
s32 sample_point_in_tc = (CAN_SYNC_SEG + dbt->prop_seg +
dbt->phase_seg1) * dbt->brp;

return (s32)dbt_params->tdc.tdco - sample_point_in_tc;
}

/*
* can_bit_time() - Duration of one bit
*
Expand Down
11 changes: 3 additions & 8 deletions src/kernel/include/linux/can/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,11 @@ struct can_priv {
struct net_device *dev;
struct can_device_stats can_stats;

const struct can_bittiming_const *bittiming_const,
*data_bittiming_const;
struct can_bittiming bittiming, data_bittiming;
const struct can_tdc_const *tdc_const;
struct can_tdc tdc;

const struct can_bittiming_const *bittiming_const;
struct can_bittiming bittiming;
struct data_bittiming_params fd;
unsigned int bitrate_const_cnt;
const u32 *bitrate_const;
const u32 *data_bitrate_const;
unsigned int data_bitrate_const_cnt;
u32 bitrate_max;
struct can_clock clock;

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,

#endif /* __KERNEL__ */

#if defined(CONFIG_CFI_CLANG) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO)
#if defined(CONFIG_CFI) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO)
/*
* Force a reference to the external symbol so the compiler generates
* __kcfi_typid.
Expand Down
20 changes: 11 additions & 9 deletions src/kernel/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,17 +808,19 @@ struct net_device_ops {
*/

struct net_device {
char name[IFNAMSIZ];
unsigned int irq;
const struct net_device_ops *netdev_ops;
unsigned int mtu;
unsigned long state;
struct net_device_stats stats;
unsigned int flags;
unsigned int mtu;
const struct net_device_ops *netdev_ops;
const struct resmgr_ops *resmgr_ops;
unsigned short dev_id;
unsigned long tx_queue_len;
unsigned int flags;
char name[IFNAMSIZ];
unsigned int min_mtu;
unsigned int max_mtu;
struct net_device_stats stats; /* not used by modern drivers */
unsigned short dev_id;
int irq;
unsigned int tx_queue_len;
void* priv;
const struct resmgr_ops *resmgr_ops;
struct device_session* device_session;
};

Expand Down
Loading
Loading