Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

eth: fbnic: move xdp_rxq_info_reg() to resource alloc

Move rxq_info and mem model registration from fbnic_alloc_napi_vector()
and fbnic_alloc_nv_resources() to fbnic_alloc_rx_qt_resources().
The rxq_info is now registered later in the process, but that
should not cause any issues.

rxq_info lives in the fbnic_q_triad (qt) struct so qt init is a more
natural place. Encapsulating the logic in the qt functions will also
allow simplifying the cleanup in the NAPI related alloc functions
in the next commit.

Rx does not have a dedicated fbnic_free_rx_qt_resources(),
but we can use xdp_rxq_info_is_reg() to tell whether given
rxq_info was in use (effectively - if it's a qt for an Rx queue).

Having to pass nv into fbnic_alloc_rx_qt_resources() is not
great in terms of layering, but that's temporary, pp will
move soon..

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250901211214.1027927-3-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jakub Kicinski and committed by
Paolo Abeni
894d4a4e 33478dca

+26 -32
+26 -32
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
··· 1482 1482 } 1483 1483 1484 1484 for (j = 0; j < nv->rxt_count; j++, i++) { 1485 - xdp_rxq_info_unreg(&nv->qt[i].xdp_rxq); 1486 1485 fbnic_remove_rx_ring(fbn, &nv->qt[i].sub0); 1487 1486 fbnic_remove_rx_ring(fbn, &nv->qt[i].sub1); 1488 1487 fbnic_remove_rx_ring(fbn, &nv->qt[i].cmpl); ··· 1685 1686 if (err) 1686 1687 goto free_ring_cur_qt; 1687 1688 1688 - err = xdp_rxq_info_reg(&qt->xdp_rxq, fbn->netdev, rxq_idx, 1689 - nv->napi.napi_id); 1690 - if (err) 1691 - goto free_qt_pp; 1692 - 1693 1689 /* Update Rx queue index */ 1694 1690 rxt_count--; 1695 1691 rxq_idx += v_count; ··· 1698 1704 while (rxt_count < nv->rxt_count) { 1699 1705 qt--; 1700 1706 1701 - xdp_rxq_info_unreg(&qt->xdp_rxq); 1702 - free_qt_pp: 1703 1707 fbnic_free_qt_page_pools(qt); 1704 1708 free_ring_cur_qt: 1705 1709 fbnic_remove_rx_ring(fbn, &qt->sub0); ··· 1930 1938 fbnic_free_ring_resources(dev, &qt->cmpl); 1931 1939 fbnic_free_ring_resources(dev, &qt->sub1); 1932 1940 fbnic_free_ring_resources(dev, &qt->sub0); 1941 + 1942 + if (xdp_rxq_info_is_reg(&qt->xdp_rxq)) { 1943 + xdp_rxq_info_unreg_mem_model(&qt->xdp_rxq); 1944 + xdp_rxq_info_unreg(&qt->xdp_rxq); 1945 + } 1933 1946 } 1934 1947 1935 1948 static int fbnic_alloc_tx_qt_resources(struct fbnic_net *fbn, ··· 1965 1968 } 1966 1969 1967 1970 static int fbnic_alloc_rx_qt_resources(struct fbnic_net *fbn, 1971 + struct fbnic_napi_vector *nv, 1968 1972 struct fbnic_q_triad *qt) 1969 1973 { 1970 1974 struct device *dev = fbn->netdev->dev.parent; 1971 1975 int err; 1972 1976 1973 - err = fbnic_alloc_rx_ring_resources(fbn, &qt->sub0); 1977 + err = xdp_rxq_info_reg(&qt->xdp_rxq, fbn->netdev, qt->sub0.q_idx, 1978 + nv->napi.napi_id); 1974 1979 if (err) 1975 1980 return err; 1981 + 1982 + /* Register XDP memory model for completion queue */ 1983 + err = xdp_rxq_info_reg_mem_model(&qt->xdp_rxq, MEM_TYPE_PAGE_POOL, 1984 + qt->sub0.page_pool); 1985 + if (err) 1986 + goto unreg_rxq; 1987 + 1988 + err = fbnic_alloc_rx_ring_resources(fbn, &qt->sub0); 1989 + if (err) 1990 + goto unreg_mm; 1976 1991 1977 1992 err = fbnic_alloc_rx_ring_resources(fbn, &qt->sub1); 1978 1993 if (err) ··· 2000 1991 fbnic_free_ring_resources(dev, &qt->sub1); 2001 1992 free_sub0: 2002 1993 fbnic_free_ring_resources(dev, &qt->sub0); 1994 + unreg_mm: 1995 + xdp_rxq_info_unreg_mem_model(&qt->xdp_rxq); 1996 + unreg_rxq: 1997 + xdp_rxq_info_unreg(&qt->xdp_rxq); 2003 1998 return err; 2004 1999 } 2005 2000 2006 2001 static void fbnic_free_nv_resources(struct fbnic_net *fbn, 2007 2002 struct fbnic_napi_vector *nv) 2008 2003 { 2009 - int i, j; 2004 + int i; 2010 2005 2011 - /* Free Tx Resources */ 2012 - for (i = 0; i < nv->txt_count; i++) 2006 + for (i = 0; i < nv->txt_count + nv->rxt_count; i++) 2013 2007 fbnic_free_qt_resources(fbn, &nv->qt[i]); 2014 - 2015 - for (j = 0; j < nv->rxt_count; j++, i++) { 2016 - fbnic_free_qt_resources(fbn, &nv->qt[i]); 2017 - xdp_rxq_info_unreg_mem_model(&nv->qt[i].xdp_rxq); 2018 - } 2019 2008 } 2020 2009 2021 2010 static int fbnic_alloc_nv_resources(struct fbnic_net *fbn, ··· 2030 2023 2031 2024 /* Allocate Rx Resources */ 2032 2025 for (j = 0; j < nv->rxt_count; j++, i++) { 2033 - /* Register XDP memory model for completion queue */ 2034 - err = xdp_reg_mem_model(&nv->qt[i].xdp_rxq.mem, 2035 - MEM_TYPE_PAGE_POOL, 2036 - nv->qt[i].sub0.page_pool); 2026 + err = fbnic_alloc_rx_qt_resources(fbn, nv, &nv->qt[i]); 2037 2027 if (err) 2038 - goto xdp_unreg_mem_model; 2039 - 2040 - err = fbnic_alloc_rx_qt_resources(fbn, &nv->qt[i]); 2041 - if (err) 2042 - goto xdp_unreg_cur_model; 2028 + goto free_qt_resources; 2043 2029 } 2044 2030 2045 2031 return 0; 2046 2032 2047 - xdp_unreg_mem_model: 2048 - while (j-- && i--) { 2049 - fbnic_free_qt_resources(fbn, &nv->qt[i]); 2050 - xdp_unreg_cur_model: 2051 - xdp_rxq_info_unreg_mem_model(&nv->qt[i].xdp_rxq); 2052 - } 2053 2033 free_qt_resources: 2054 2034 while (i--) 2055 2035 fbnic_free_qt_resources(fbn, &nv->qt[i]);