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.

xen/netfront: use xenbus_setup_ring() and xenbus_teardown_ring()

Simplify netfront's ring creation and removal via xenbus_setup_ring()
and xenbus_teardown_ring().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+12 -41
+12 -41
drivers/net/xen-netfront.c
··· 1921 1921 struct netfront_queue *queue, unsigned int feature_split_evtchn) 1922 1922 { 1923 1923 struct xen_netif_tx_sring *txs; 1924 - struct xen_netif_rx_sring *rxs = NULL; 1925 - grant_ref_t gref; 1924 + struct xen_netif_rx_sring *rxs; 1926 1925 int err; 1927 1926 1928 1927 queue->tx_ring_ref = INVALID_GRANT_REF; ··· 1929 1930 queue->rx.sring = NULL; 1930 1931 queue->tx.sring = NULL; 1931 1932 1932 - txs = (struct xen_netif_tx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH); 1933 - if (!txs) { 1934 - err = -ENOMEM; 1935 - xenbus_dev_fatal(dev, err, "allocating tx ring page"); 1933 + err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&txs, 1934 + 1, &queue->tx_ring_ref); 1935 + if (err) 1936 1936 goto fail; 1937 - } 1938 - SHARED_RING_INIT(txs); 1939 - FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); 1940 1937 1941 - err = xenbus_grant_ring(dev, txs, 1, &gref); 1942 - if (err < 0) 1943 - goto fail; 1944 - queue->tx_ring_ref = gref; 1938 + XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); 1945 1939 1946 - rxs = (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH); 1947 - if (!rxs) { 1948 - err = -ENOMEM; 1949 - xenbus_dev_fatal(dev, err, "allocating rx ring page"); 1940 + err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs, 1941 + 1, &queue->rx_ring_ref); 1942 + if (err) 1950 1943 goto fail; 1951 - } 1952 - SHARED_RING_INIT(rxs); 1953 - FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); 1954 1944 1955 - err = xenbus_grant_ring(dev, rxs, 1, &gref); 1956 - if (err < 0) 1957 - goto fail; 1958 - queue->rx_ring_ref = gref; 1945 + XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); 1959 1946 1960 1947 if (feature_split_evtchn) 1961 1948 err = setup_netfront_split(queue); ··· 1957 1972 1958 1973 return 0; 1959 1974 1960 - /* If we fail to setup netfront, it is safe to just revoke access to 1961 - * granted pages because backend is not accessing it at this point. 1962 - */ 1963 1975 fail: 1964 - if (queue->rx_ring_ref != INVALID_GRANT_REF) { 1965 - gnttab_end_foreign_access(queue->rx_ring_ref, 1966 - (unsigned long)rxs); 1967 - queue->rx_ring_ref = INVALID_GRANT_REF; 1968 - } else { 1969 - free_page((unsigned long)rxs); 1970 - } 1971 - if (queue->tx_ring_ref != INVALID_GRANT_REF) { 1972 - gnttab_end_foreign_access(queue->tx_ring_ref, 1973 - (unsigned long)txs); 1974 - queue->tx_ring_ref = INVALID_GRANT_REF; 1975 - } else { 1976 - free_page((unsigned long)txs); 1977 - } 1976 + xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref); 1977 + xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref); 1978 + 1978 1979 return err; 1979 1980 } 1980 1981