Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions boards/nxp/mr_canhubk3/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ flexcan5 | PTC11 | PTC11_CAN0_RX P22/P23
and support maximum 32 message buffers for concurrent active instances with 8 bytes
payload. We need to pay attention to configuration options:

1. :kconfig:option:`CONFIG_CAN_MAX_MB` must be less or equal than the
1. :kconfig:option:`CONFIG_CAN_MCUX_FLEXCAN_MAX_MB` must be less or equal than the
maximum number of message buffers that is according to the table below.

2. :kconfig:option:`CONFIG_CAN_MAX_FILTER` must be less or equal than
:kconfig:option:`CONFIG_CAN_MAX_MB`.
2. :kconfig:option:`CONFIG_CAN_MCUX_FLEXCAN_MAX_FILTERS` must be less or equal than
:kconfig:option:`CONFIG_CAN_MCUX_FLEXCAN_MAX_MB`.

=============== ========== ================ ================
Devicetree node Payload Hardware support Software support
Expand Down
25 changes: 25 additions & 0 deletions doc/releases/migration-guide-4.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ Device Drivers and Devicetree

.. zephyr-keep-sorted-start re(^\w)

Controller Area Network (CAN)
=============================

* Removed ``CONFIG_CAN_MAX_FILTER``, ``CONFIG_CAN_MAX_STD_ID_FILTER``,
``CONFIG_CAN_MAX_EXT_ID_FILTER``, and ``CONFIG_CAN_MAX_MB`` (:github:`100596`). These are replaced
by the following driver-specific Kconfig symbols, some of which have had their default value
increased to meet typical software needs:

* :kconfig:option:`CONFIG_CAN_LOOPBACK_MAX_FILTERS` for :dtcompatible:`zephyr,can-loopback`
* :kconfig:option:`CONFIG_CAN_MAX32_MAX_FILTERS` for :dtcompatible:`adi,max32-can`
* :kconfig:option:`CONFIG_CAN_MCP2515_MAX_FILTERS` for :dtcompatible:`microchip,mcp2515`
* :kconfig:option:`CONFIG_CAN_MCP251XFD_MAX_FILTERS` for :dtcompatible:`microchip,mcp251xfd`
* :kconfig:option:`CONFIG_CAN_MCUX_FLEXCAN_MAX_FILTERS` for :dtcompatible:`nxp,flexcan`
* :kconfig:option:`CONFIG_CAN_MCUX_FLEXCAN_MAX_MB` for :dtcompatible:`nxp,flexcan`
* :kconfig:option:`CONFIG_CAN_NATIVE_LINUX_MAX_FILTERS` for
:dtcompatible:`zephyr,native-linux-can`
* :kconfig:option:`CONFIG_CAN_RCAR_MAX_FILTERS` for :dtcompatible:`renesas,rcar-can`
* :kconfig:option:`CONFIG_CAN_SJA1000_MAX_FILTERS` for :dtcompatible:`kvaser,pcican` and
:dtcompatible:`espressif,esp32-twai`
* :kconfig:option:`CONFIG_CAN_STM32_BXCAN_MAX_EXT_ID_FILTERS` for :dtcompatible:`st,stm32-bxcan`
* :kconfig:option:`CONFIG_CAN_STM32_BXCAN_MAX_STD_ID_FILTERS` for :dtcompatible:`st,stm32-bxcan`
* :kconfig:option:`CONFIG_CAN_STM32_FDCAN_MAX_EXT_ID_FILTERS` for :dtcompatible:`st,stm32-fdcan`
* :kconfig:option:`CONFIG_CAN_STM32_FDCAN_MAX_STD_ID_FILTERS` for :dtcompatible:`st,stm32-fdcan`
* :kconfig:option:`CONFIG_CAN_XMC4XXX_MAX_FILTERS` for :dtcompatible:`infineon,xmc4xxx-can-node`

Ethernet
========

Expand Down
2 changes: 1 addition & 1 deletion drivers/can/Kconfig.loopback
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config CAN_LOOPBACK

if CAN_LOOPBACK

config CAN_MAX_FILTER
config CAN_LOOPBACK_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 16
range 1 1024
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.max32
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ config CAN_MAX32

if CAN_MAX32

config CAN_MAX_FILTER
config CAN_MAX32_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 5
default 16
range 1 32
help
Maximum number of filters supported by the can_add_rx_callback() API call.
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.mcp2515
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ config CAN_MCP2515_INT_THREAD_PRIO
Priority level of the internal thread which is ran for
interrupt handling and incoming packets.

config CAN_MAX_FILTER
config CAN_MCP2515_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 5
default 16
range 1 32
help
Defines the array size of the callback/msgq pointers.
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.mcp251xfd
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ config CAN_MCP251XFD_READ_CRC_RETRIES
help
Number of retries during SFR register read if CRC fails.

config CAN_MAX_FILTER
config CAN_MCP251XFD_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 5
default 16
range 1 32
help
Maximum number of filters supported by the can_add_rx_callback() API call.
Expand Down
6 changes: 3 additions & 3 deletions drivers/can/Kconfig.mcux
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config CAN_MCUX_FLEXCAN_WAIT_TIMEOUT
Maximum number of wait loop iterations for the MCUX FlexCAN HAL when entering/leaving
freeze mode.

config CAN_MAX_MB
config CAN_MCUX_FLEXCAN_MAX_MB
int "Maximum number of message buffers for concurrent active instances"
default 16
depends on SOC_SERIES_S32K3 || SOC_SERIES_S32K1 || SOC_SERIES_S32ZE
Expand All @@ -39,9 +39,9 @@ config CAN_MAX_MB
help
Defines maximum number of message buffers for concurrent active instances.

config CAN_MAX_FILTER
config CAN_MCUX_FLEXCAN_MAX_FILTERS
int "Maximum number of concurrent active RX filters"
default 5
default 13
range 1 15 if SOC_SERIES_KINETIS_KE1XF || SOC_SERIES_KINETIS_K6X
range 1 13 if (SOC_SERIES_IMXRT10XX || SOC_SERIES_IMXRT11XX) && CAN_MCUX_FLEXCAN_FD
range 1 63 if SOC_SERIES_IMXRT10XX || SOC_SERIES_IMXRT11XX
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.native_linux
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ config CAN_NATIVE_LINUX_RX_THREAD_PRIORITY
Priority level of the internal thread which is run for
handling of incoming packets.

config CAN_MAX_FILTER
config CAN_NATIVE_LINUX_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 5
default 16
range 1 32
help
Defines the array size of the callback/msgq pointers.
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.rcar
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ config CAN_RCAR
help
Enable Renesas R-Car CAN Driver.

config CAN_RCAR_MAX_FILTER
config CAN_RCAR_MAX_FILTERS
int "Maximum number of concurrent active filters"
depends on CAN_RCAR
default 5
default 16
range 1 32
help
Defines the array size of the callback/msgq pointers.
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.sja1000
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ config CAN_SJA1000
help
This enables support for the shared NXP SJA1000 CAN driver.

config CAN_MAX_FILTER
config CAN_SJA1000_MAX_FILTERS
int "Maximum number of concurrent active RX filters"
depends on CAN_SJA1000
default 5
default 16
range 1 32
help
As the NXP SJA1000 only supports one full-width RX filter, filtering of received CAN
Expand Down
12 changes: 6 additions & 6 deletions drivers/can/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ config CAN_STM32_BXCAN

if CAN_STM32_BXCAN

config CAN_MAX_STD_ID_FILTER
config CAN_STM32_BXCAN_MAX_STD_ID_FILTERS
int "Maximum number of standard (11-bit) ID filters"
default 14
range 0 28
Expand All @@ -28,9 +28,9 @@ config CAN_MAX_STD_ID_FILTER
The following equation determines the maximum total number of
filters:

CAN_MAX_STD_ID_FILTER + CAN_MAX_EXT_ID_FILTER * 2 <= 28
CAN_STM32_BXCAN_MAX_STD_ID_FILTERS + CAN_STM32_BXCAN_MAX_EXT_ID_FILTERS * 2 <= 28

config CAN_MAX_EXT_ID_FILTER
config CAN_STM32_BXCAN_MAX_EXT_ID_FILTERS
int "Maximum number of extended (29-bit) ID filters"
default 7
range 0 14
Expand All @@ -44,7 +44,7 @@ config CAN_MAX_EXT_ID_FILTER
The following equation determines the maximum total number of
filters:

CAN_MAX_STD_ID_FILTER + CAN_MAX_EXT_ID_FILTER * 2 <= 28
CAN_STM32_BXCAN_MAX_STD_ID_FILTERS + CAN_STM32_BXCAN_MAX_EXT_ID_FILTERS * 2 <= 28

endif # CAN_STM32_BXCAN

Expand All @@ -57,15 +57,15 @@ config CAN_STM32_FDCAN

if CAN_STM32_FDCAN

config CAN_MAX_STD_ID_FILTER
config CAN_STM32_FDCAN_MAX_STD_ID_FILTERS
int "Maximum number of standard (11-bit) ID filters"
default 28
range 0 28
help
Defines the maximum number of filters with standard ID (11-bit)
that can be added by the application.

config CAN_MAX_EXT_ID_FILTER
config CAN_STM32_FDCAN_MAX_EXT_ID_FILTERS
int "Maximum number of extended (29-bit) ID filters"
default 8
range 0 8
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig.xmc4xxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ config CAN_XMC4XXX_INTERNAL_BUS_MODE
Connects all XMC4XXX CAN devices to an internal bus. Enables
message exchange between MCU CAN devices without any external connectors.

config CAN_MAX_FILTER
config CAN_XMC4XXX_MAX_FILTERS
int "Maximum number of concurrent active filters"
default 4
default 16
range 1 32
help
Maximum number of filters supported by the can_add_rx_callback() API call.
Expand Down
10 changes: 5 additions & 5 deletions drivers/can/can_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct can_loopback_config {

struct can_loopback_data {
struct can_driver_data common;
struct can_loopback_filter filters[CONFIG_CAN_MAX_FILTER];
struct can_loopback_filter filters[CONFIG_CAN_LOOPBACK_MAX_FILTERS];
struct k_mutex mtx;
struct k_msgq tx_msgq;
char msgq_buffer[CONFIG_CAN_LOOPBACK_TX_MSGQ_SIZE * sizeof(struct can_loopback_frame)];
Expand Down Expand Up @@ -90,7 +90,7 @@ static void tx_thread(void *arg1, void *arg2, void *arg3)

k_mutex_lock(&data->mtx, K_FOREVER);

for (int i = 0; i < CONFIG_CAN_MAX_FILTER; i++) {
for (int i = 0; i < CONFIG_CAN_LOOPBACK_MAX_FILTERS; i++) {
filter = &data->filters[i];
if (filter->rx_cb != NULL &&
can_frame_matches_filter(&frame.frame, &filter->filter)) {
Expand Down Expand Up @@ -163,7 +163,7 @@ static int can_loopback_send(const struct device *dev,

static inline int get_free_filter(struct can_loopback_filter *filters)
{
for (int i = 0; i < CONFIG_CAN_MAX_FILTER; i++) {
for (int i = 0; i < CONFIG_CAN_LOOPBACK_MAX_FILTERS; i++) {
if (filters[i].rx_cb == NULL) {
return i;
}
Expand Down Expand Up @@ -362,7 +362,7 @@ static int can_loopback_get_max_filters(const struct device *dev, bool ide)
{
ARG_UNUSED(ide);

return CONFIG_CAN_MAX_FILTER;
return CONFIG_CAN_LOOPBACK_MAX_FILTERS;
}

static DEVICE_API(can, can_loopback_driver_api) = {
Expand Down Expand Up @@ -420,7 +420,7 @@ static int can_loopback_init(const struct device *dev)

k_mutex_init(&data->mtx);

for (int i = 0; i < CONFIG_CAN_MAX_FILTER; i++) {
for (int i = 0; i < CONFIG_CAN_LOOPBACK_MAX_FILTERS; i++) {
data->filters[i].rx_cb = NULL;
}

Expand Down
16 changes: 9 additions & 7 deletions drivers/can/can_max32.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct max32_can_data {
struct max32_req_data tx_data;

uint32_t filter_usage;
struct max32_can_rx_callback rx_callbacks[CONFIG_CAN_MAX_FILTER];
struct max32_can_rx_callback rx_callbacks[CONFIG_CAN_MAX32_MAX_FILTERS];
struct max32_req_data rx_data;
};

Expand Down Expand Up @@ -352,12 +352,13 @@ static int can_max32_add_rx_filter(const struct device *dev, can_rx_callback_t c
k_mutex_lock(&dev_data->inst_mutex, K_FOREVER);

/* find free filter */
while ((BIT(filter_idx) & dev_data->filter_usage) && (filter_idx < CONFIG_CAN_MAX_FILTER)) {
while ((BIT(filter_idx) & dev_data->filter_usage) &&
(filter_idx < CONFIG_CAN_MAX32_MAX_FILTERS)) {
filter_idx++;
}

/* setup filter */
if (filter_idx < CONFIG_CAN_MAX_FILTER) {
if (filter_idx < CONFIG_CAN_MAX32_MAX_FILTERS) {
unsigned int key = irq_lock();

dev_data->filter_usage |= BIT(filter_idx);
Expand All @@ -371,7 +372,8 @@ static int can_max32_add_rx_filter(const struct device *dev, can_rx_callback_t c
LOG_DBG("Set filter id:%08X mask:%08X", filter->id, filter->mask);
} else {
filter_idx = -ENOSPC;
LOG_WRN("All filters are used CONFIG_CAN_MAX_FILTER=%d", CONFIG_CAN_MAX_FILTER);
LOG_WRN("All filters are used CONFIG_CAN_MAX32_MAX_FILTERS=%d",
CONFIG_CAN_MAX32_MAX_FILTERS);
}

k_mutex_unlock(&dev_data->inst_mutex);
Expand All @@ -384,7 +386,7 @@ static void can_max32_remove_rx_filter(const struct device *dev, int filter_idx)
struct max32_can_data *dev_data = dev->data;
unsigned int key;

if ((filter_idx < 0) || (filter_idx >= CONFIG_CAN_MAX_FILTER)) {
if ((filter_idx < 0) || (filter_idx >= CONFIG_CAN_MAX32_MAX_FILTERS)) {
LOG_ERR("Filter ID %d out of bounds", filter_idx);
return;
}
Expand Down Expand Up @@ -465,7 +467,7 @@ static int can_max32_get_max_filters(const struct device *dev, bool ide)
ARG_UNUSED(dev);
ARG_UNUSED(ide);

return CONFIG_CAN_MAX_FILTER;
return CONFIG_CAN_MAX32_MAX_FILTERS;
}

#ifdef CONFIG_CAN_MANUAL_RECOVERY_MODE
Expand Down Expand Up @@ -510,7 +512,7 @@ static void can_max32_rx_soft_filter(const struct device *dev, struct can_frame
}
#endif /* !CONFIG_CAN_ACCEPT_RTR */

for (; filter_id < CONFIG_CAN_MAX_FILTER; filter_id++) {
for (; filter_id < CONFIG_CAN_MAX32_MAX_FILTERS; filter_id++) {
if (!(BIT(filter_id) & dev_data->filter_usage)) {
continue; /* filter slot empty */
}
Expand Down
11 changes: 6 additions & 5 deletions drivers/can/can_mcp2515.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int mcp2515_get_max_filters(const struct device *dev, bool ide)
{
ARG_UNUSED(ide);

return CONFIG_CAN_MAX_FILTER;
return CONFIG_CAN_MCP2515_MAX_FILTERS;
}

static int mcp2515_set_timing(const struct device *dev, const struct can_timing *timing)
Expand Down Expand Up @@ -622,12 +622,13 @@ static int mcp2515_add_rx_filter(const struct device *dev, can_rx_callback_t rx_
k_mutex_lock(&dev_data->mutex, K_FOREVER);

/* find free filter */
while ((BIT(filter_id) & dev_data->filter_usage) && (filter_id < CONFIG_CAN_MAX_FILTER)) {
while ((BIT(filter_id) & dev_data->filter_usage) &&
(filter_id < CONFIG_CAN_MCP2515_MAX_FILTERS)) {
filter_id++;
}

/* setup filter */
if (filter_id < CONFIG_CAN_MAX_FILTER) {
if (filter_id < CONFIG_CAN_MCP2515_MAX_FILTERS) {
dev_data->filter_usage |= BIT(filter_id);

dev_data->filter[filter_id] = *filter;
Expand All @@ -647,7 +648,7 @@ static void mcp2515_remove_rx_filter(const struct device *dev, int filter_id)
{
struct mcp2515_data *dev_data = dev->data;

if (filter_id < 0 || filter_id >= CONFIG_CAN_MAX_FILTER) {
if (filter_id < 0 || filter_id >= CONFIG_CAN_MCP2515_MAX_FILTERS) {
LOG_ERR("filter ID %d out of bounds", filter_id);
return;
}
Expand Down Expand Up @@ -681,7 +682,7 @@ static void mcp2515_rx_filter(const struct device *dev, struct can_frame *frame)

k_mutex_lock(&dev_data->mutex, K_FOREVER);

for (; filter_id < CONFIG_CAN_MAX_FILTER; filter_id++) {
for (; filter_id < CONFIG_CAN_MCP2515_MAX_FILTERS; filter_id++) {
if (!(BIT(filter_id) & dev_data->filter_usage)) {
continue; /* filter slot empty */
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/can/can_mcp2515.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ struct mcp2515_data {

/* filter data */
uint32_t filter_usage;
can_rx_callback_t rx_cb[CONFIG_CAN_MAX_FILTER];
void *cb_arg[CONFIG_CAN_MAX_FILTER];
struct can_filter filter[CONFIG_CAN_MAX_FILTER];
can_rx_callback_t rx_cb[CONFIG_CAN_MCP2515_MAX_FILTERS];
void *cb_arg[CONFIG_CAN_MCP2515_MAX_FILTERS];
struct can_filter filter[CONFIG_CAN_MCP2515_MAX_FILTERS];

/* general data */
struct k_mutex mutex;
Expand Down
Loading