On 08/22, Jakub Kicinski wrote:
> Improve HDS handling. Make sure we set threshold to 0.
> Restore the previous settings before exiting.
> 
> Signed-off-by: Jakub Kicinski <[email protected]>
> ---
>  .../selftests/drivers/net/hw/ncdevmem.c       | 96 +++++++++++++++++--
>  1 file changed, 87 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c 
> b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> index 580b4459a840..aa2904d1a3e1 100644
> --- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> +++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> @@ -419,6 +419,60 @@ static const char *tcp_data_split_str(int val)
>       }
>  }
>  
> +static struct ethtool_rings_get_rsp *get_ring_config(void)
> +{
> +     struct ethtool_rings_get_req *get_req;
> +     struct ethtool_rings_get_rsp *get_rsp;
> +     struct ynl_error yerr;
> +     struct ynl_sock *ys;
> +
> +     ys = ynl_sock_create(&ynl_ethtool_family, &yerr);
> +     if (!ys) {
> +             fprintf(stderr, "YNL: %s\n", yerr.msg);
> +             return NULL;
> +     }
> +
> +     get_req = ethtool_rings_get_req_alloc();
> +     ethtool_rings_get_req_set_header_dev_index(get_req, ifindex);
> +     get_rsp = ethtool_rings_get(ys, get_req);
> +     ethtool_rings_get_req_free(get_req);
> +
> +     ynl_sock_destroy(ys);
> +
> +     return get_rsp;
> +}
> +
> +static void restore_ring_config(const struct ethtool_rings_get_rsp *config)
> +{
> +     struct ethtool_rings_set_req *req;
> +     struct ynl_error yerr;
> +     struct ynl_sock *ys;
> +     int ret;
> +
> +     if (!config)
> +             return;
> +
> +     ys = ynl_sock_create(&ynl_ethtool_family, &yerr);
> +     if (!ys) {
> +             fprintf(stderr, "YNL: %s\n", yerr.msg);
> +             return;
> +     }
> +
> +     req = ethtool_rings_set_req_alloc();
> +     ethtool_rings_set_req_set_header_dev_index(req, ifindex);
> +     ethtool_rings_set_req_set_tcp_data_split(req,
> +                                             ETHTOOL_TCP_DATA_SPLIT_UNKNOWN);
> +     if (config->_present.hds_thresh)
> +             ethtool_rings_set_req_set_hds_thresh(req, config->hds_thresh);
> +
> +     ret = ethtool_rings_set(ys, req);
> +     if (ret < 0)
> +             fprintf(stderr, "YNL failed: %s\n", ys->err.msg);
> +     ethtool_rings_set_req_free(req);
> +
> +     ynl_sock_destroy(ys);
> +}
> +
>  static int configure_headersplit(bool on)
>  {
>       struct ethtool_rings_get_req *get_req;
> @@ -436,8 +490,14 @@ static int configure_headersplit(bool on)
>  
>       req = ethtool_rings_set_req_alloc();
>       ethtool_rings_set_req_set_header_dev_index(req, ifindex);
> -     /* 0 - off, 1 - auto, 2 - on */
> -     ethtool_rings_set_req_set_tcp_data_split(req, on ? 2 : 0);
> +     if (on) {
> +             ethtool_rings_set_req_set_tcp_data_split(req,
> +                                             ETHTOOL_TCP_DATA_SPLIT_ENABLED);
> +             ethtool_rings_set_req_set_hds_thresh(req, 0);

>From talking to Taehee awhile ago it seemed like unconditionally
setting 0 will fail on the devices that don't support it.
Is it not the case anymore with ethnl_set_rings_validate?

Reply via email to