Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gve/gve_main.c
| Show All 29 Lines | |||||
| */ | */ | ||||
| #include "gve.h" | #include "gve.h" | ||||
| #include "gve_adminq.h" | #include "gve_adminq.h" | ||||
| #include "gve_dqo.h" | #include "gve_dqo.h" | ||||
| #define GVE_DRIVER_VERSION "GVE-FBSD-1.3.4\n" | #define GVE_DRIVER_VERSION "GVE-FBSD-1.3.4\n" | ||||
| #define GVE_VERSION_MAJOR 1 | #define GVE_VERSION_MAJOR 1 | ||||
| #define GVE_VERSION_MINOR 3 | #define GVE_VERSION_MINOR 3 | ||||
| #define GVE_VERSION_SUB 4 | #define GVE_VERSION_SUB 5 | ||||
| #define GVE_DEFAULT_RX_COPYBREAK 256 | #define GVE_DEFAULT_RX_COPYBREAK 256 | ||||
| /* Devices supported by this driver. */ | /* Devices supported by this driver. */ | ||||
| static struct gve_dev { | static struct gve_dev { | ||||
| uint16_t vendor_id; | uint16_t vendor_id; | ||||
| uint16_t device_id; | uint16_t device_id; | ||||
| const char *name; | const char *name; | ||||
| ▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | if (err != 0) { | ||||
| gve_schedule_reset(priv); | gve_schedule_reset(priv); | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static int | static int | ||||
| gve_get_dqo_rx_buf_size(struct gve_priv *priv, uint16_t mtu) | |||||
| { | |||||
| /* | |||||
| * Use 4k buffers only if mode is DQ, 4k buffers flag is on, | |||||
| * and either hw LRO is enabled or mtu is greater than 2048 | |||||
| */ | |||||
| if (!gve_is_gqi(priv) && gve_allow_4k_rx_buffers && | |||||
| (!gve_disable_hw_lro || mtu > GVE_DEFAULT_RX_BUFFER_SIZE)) | |||||
| return (GVE_4K_RX_BUFFER_SIZE_DQO); | |||||
| return (GVE_DEFAULT_RX_BUFFER_SIZE); | |||||
| } | |||||
| static int | |||||
| gve_set_mtu(if_t ifp, uint32_t new_mtu) | gve_set_mtu(if_t ifp, uint32_t new_mtu) | ||||
| { | { | ||||
| struct gve_priv *priv = if_getsoftc(ifp); | struct gve_priv *priv = if_getsoftc(ifp); | ||||
| const uint32_t max_problem_range = 8227; | const uint32_t max_problem_range = 8227; | ||||
| const uint32_t min_problem_range = 7822; | const uint32_t min_problem_range = 7822; | ||||
| uint16_t new_rx_buf_size = gve_get_dqo_rx_buf_size(priv, new_mtu); | |||||
| int err; | int err; | ||||
| if ((new_mtu > priv->max_mtu) || (new_mtu < ETHERMIN)) { | if ((new_mtu > priv->max_mtu) || (new_mtu < ETHERMIN)) { | ||||
| device_printf(priv->dev, "Invalid new MTU setting. new mtu: %d max mtu: %d min mtu: %d\n", | device_printf(priv->dev, "Invalid new MTU setting. new mtu: %d max mtu: %d min mtu: %d\n", | ||||
| new_mtu, priv->max_mtu, ETHERMIN); | new_mtu, priv->max_mtu, ETHERMIN); | ||||
| return (EINVAL); | return (EINVAL); | ||||
| } | } | ||||
| /* | /* | ||||
markj: I think this driver tries to follow the style(9) convention of declaring variables at the… | |||||
| * When hardware LRO is enabled in DQ mode, MTUs within the range | * When hardware LRO is enabled in DQ mode, MTUs within the range | ||||
| * [7822, 8227] trigger hardware issues which cause a drastic drop | * [7822, 8227] trigger hardware issues which cause a drastic drop | ||||
| * in throughput. | * in throughput. | ||||
| */ | */ | ||||
| if (!gve_is_gqi(priv) && !gve_disable_hw_lro && | if (!gve_is_gqi(priv) && !gve_disable_hw_lro && | ||||
| new_mtu >= min_problem_range && new_mtu <= max_problem_range) { | new_mtu >= min_problem_range && new_mtu <= max_problem_range && | ||||
| new_rx_buf_size != GVE_4K_RX_BUFFER_SIZE_DQO) { | |||||
| device_printf(priv->dev, | device_printf(priv->dev, | ||||
| "Cannot set to MTU to %d within the range [%d, %d] while hardware LRO is enabled\n", | "Cannot set to MTU to %d within the range [%d, %d] while HW LRO is enabled and not using 4k RX Buffers\n", | ||||
| new_mtu, min_problem_range, max_problem_range); | new_mtu, min_problem_range, max_problem_range); | ||||
| return (EINVAL); | return (EINVAL); | ||||
| } | } | ||||
| err = gve_adminq_set_mtu(priv, new_mtu); | err = gve_adminq_set_mtu(priv, new_mtu); | ||||
| if (err == 0) { | if (err == 0) { | ||||
| if (bootverbose) | if (bootverbose) | ||||
| device_printf(priv->dev, "MTU set to %d\n", new_mtu); | device_printf(priv->dev, "MTU set to %d\n", new_mtu); | ||||
| if_setmtu(ifp, new_mtu); | if_setmtu(ifp, new_mtu); | ||||
| /* Need to re-alloc RX queues if RX buffer size changed */ | |||||
| if (!gve_is_gqi(priv) && | |||||
| new_rx_buf_size != priv->rx_buf_size_dqo) { | |||||
| gve_free_rx_rings(priv, 0, priv->rx_cfg.num_queues); | |||||
| priv->rx_buf_size_dqo = new_rx_buf_size; | |||||
| gve_alloc_rx_rings(priv, 0, priv->rx_cfg.num_queues); | |||||
markjUnsubmitted Not Done Inline ActionsCoverity points out that we should check for errors from gve_alloc_rx_rings(). I'm not sure how to handle errors though; perhaps this routine should be reworked to try and allocate new rings earlier? markj: Coverity points out that we should check for errors from gve_alloc_rx_rings(). I'm not sure how… | |||||
| } | |||||
| } else { | } else { | ||||
| device_printf(priv->dev, "Failed to set MTU to %d\n", new_mtu); | device_printf(priv->dev, "Failed to set MTU to %d\n", new_mtu); | ||||
| } | } | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| static void | static void | ||||
| ▲ Show 20 Lines • Show All 634 Lines • ▼ Show 20 Lines | gve_attach(device_t dev) | ||||
| err = gve_alloc_adminq_and_describe_device(priv); | err = gve_alloc_adminq_and_describe_device(priv); | ||||
| if (err != 0) | if (err != 0) | ||||
| goto abort; | goto abort; | ||||
| err = gve_alloc_and_configure_device_resources(priv); | err = gve_alloc_and_configure_device_resources(priv); | ||||
| if (err != 0) | if (err != 0) | ||||
| goto abort; | goto abort; | ||||
| priv->rx_buf_size_dqo = gve_get_dqo_rx_buf_size(priv, priv->max_mtu); | |||||
| err = gve_alloc_rings(priv); | err = gve_alloc_rings(priv); | ||||
| if (err != 0) | if (err != 0) | ||||
| goto abort; | goto abort; | ||||
| gve_setup_ifnet(dev, priv); | gve_setup_ifnet(dev, priv); | ||||
| priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK; | priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK; | ||||
| ▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines | |||||
I think this driver tries to follow the style(9) convention of declaring variables at the beginning of a scope, in which case the declaration should move up.