@@ -1921,42 +1921,27 @@ static int setup_netfront(struct xenbus_device *dev,
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
1928
queue -> rx_ring_ref = INVALID_GRANT_REF ;
1930
1929
queue -> rx .sring = NULL ;
1931
1930
queue -> tx .sring = NULL ;
1932
1931
1933
- txs = (struct xen_netif_tx_sring * )get_zeroed_page (GFP_NOIO | __GFP_HIGH );
1934
- if (!txs ) {
1935
- err = - ENOMEM ;
1936
- xenbus_dev_fatal (dev , err , "allocating tx ring page" );
1932
+ err = xenbus_setup_ring (dev , GFP_NOIO | __GFP_HIGH , (void * * )& txs ,
1933
+ 1 , & queue -> tx_ring_ref );
1934
+ if (err )
1937
1935
goto fail ;
1938
- }
1939
- SHARED_RING_INIT (txs );
1940
- FRONT_RING_INIT (& queue -> tx , txs , XEN_PAGE_SIZE );
1941
1936
1942
- err = xenbus_grant_ring (dev , txs , 1 , & gref );
1943
- if (err < 0 )
1944
- goto fail ;
1945
- queue -> tx_ring_ref = gref ;
1937
+ XEN_FRONT_RING_INIT (& queue -> tx , txs , XEN_PAGE_SIZE );
1946
1938
1947
- rxs = (struct xen_netif_rx_sring * )get_zeroed_page (GFP_NOIO | __GFP_HIGH );
1948
- if (!rxs ) {
1949
- err = - ENOMEM ;
1950
- xenbus_dev_fatal (dev , err , "allocating rx ring page" );
1939
+ err = xenbus_setup_ring (dev , GFP_NOIO | __GFP_HIGH , (void * * )& rxs ,
1940
+ 1 , & queue -> rx_ring_ref );
1941
+ if (err )
1951
1942
goto fail ;
1952
- }
1953
- SHARED_RING_INIT (rxs );
1954
- FRONT_RING_INIT (& queue -> rx , rxs , XEN_PAGE_SIZE );
1955
1943
1956
- err = xenbus_grant_ring (dev , rxs , 1 , & gref );
1957
- if (err < 0 )
1958
- goto fail ;
1959
- queue -> rx_ring_ref = gref ;
1944
+ XEN_FRONT_RING_INIT (& queue -> rx , rxs , XEN_PAGE_SIZE );
1960
1945
1961
1946
if (feature_split_evtchn )
1962
1947
err = setup_netfront_split (queue );
@@ -1972,24 +1957,10 @@ static int setup_netfront(struct xenbus_device *dev,
1972
1957
1973
1958
return 0 ;
1974
1959
1975
- /* If we fail to setup netfront, it is safe to just revoke access to
1976
- * granted pages because backend is not accessing it at this point.
1977
- */
1978
1960
fail :
1979
- if (queue -> rx_ring_ref != INVALID_GRANT_REF ) {
1980
- gnttab_end_foreign_access (queue -> rx_ring_ref ,
1981
- (unsigned long )rxs );
1982
- queue -> rx_ring_ref = INVALID_GRANT_REF ;
1983
- } else {
1984
- free_page ((unsigned long )rxs );
1985
- }
1986
- if (queue -> tx_ring_ref != INVALID_GRANT_REF ) {
1987
- gnttab_end_foreign_access (queue -> tx_ring_ref ,
1988
- (unsigned long )txs );
1989
- queue -> tx_ring_ref = INVALID_GRANT_REF ;
1990
- } else {
1991
- free_page ((unsigned long )txs );
1992
- }
1961
+ xenbus_teardown_ring ((void * * )& queue -> rx .sring , 1 , & queue -> rx_ring_ref );
1962
+ xenbus_teardown_ring ((void * * )& queue -> tx .sring , 1 , & queue -> tx_ring_ref );
1963
+
1993
1964
return err ;
1994
1965
}
1995
1966
0 commit comments