hyperv/hn: Rename chimney sending buffer connect/disconnect functions.

Minor cleanup and wording in error messages.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7825
This commit is contained in:
Sepherosa Ziehau 2016-09-12 05:18:30 +00:00
parent a711c28f62
commit 0c84fbafef

View file

@ -57,9 +57,9 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver");
/*
* Forward declarations
*/
static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc);
static int hn_nvs_conn_chim(struct hn_softc *sc);
static int hn_nvs_conn_rxbuf(struct hn_softc *);
static int hv_nv_destroy_send_buffer(struct hn_softc *sc);
static int hn_nvs_disconn_chim(struct hn_softc *sc);
static int hn_nvs_disconn_rxbuf(struct hn_softc *sc);
static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu);
static void hn_nvs_sent_none(struct hn_send_ctx *sndc,
@ -231,11 +231,8 @@ cleanup:
return (error);
}
/*
* Net VSC initialize send buffer with net VSP
*/
static int
hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
hn_nvs_conn_chim(struct hn_softc *sc)
{
struct vmbus_xact *xact = NULL;
struct hn_nvs_chim_conn *chim;
@ -255,8 +252,7 @@ hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE,
&sc->hn_chim_gpadl);
if (error) {
if_printf(sc->hn_ifp, "chimney sending buffer gpadl "
"connect failed: %d\n", error);
if_printf(sc->hn_ifp, "chim gpadl conn failed: %d\n", error);
goto cleanup;
}
@ -279,7 +275,7 @@ hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len,
HN_NVS_TYPE_CHIM_CONNRESP);
if (resp == NULL) {
if_printf(sc->hn_ifp, "exec chim conn failed\n");
if_printf(sc->hn_ifp, "exec nvs chim conn failed\n");
error = EIO;
goto cleanup;
}
@ -290,14 +286,14 @@ hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
xact = NULL;
if (status != HN_NVS_STATUS_OK) {
if_printf(sc->hn_ifp, "chim conn failed: %x\n", status);
if_printf(sc->hn_ifp, "nvs chim conn failed: %x\n", status);
error = EIO;
goto cleanup;
}
if (sectsz == 0) {
if_printf(sc->hn_ifp, "zero chimney sending buffer "
"section size\n");
return 0;
return (0);
}
sc->hn_chim_szmax = sectsz;
@ -321,12 +317,12 @@ hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n",
sc->hn_chim_szmax, sc->hn_chim_cnt);
}
return 0;
return (0);
cleanup:
if (xact != NULL)
vmbus_xact_put(xact);
hv_nv_destroy_send_buffer(sc);
hn_nvs_disconn_chim(sc);
return (error);
}
@ -371,13 +367,10 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc)
return (0);
}
/*
* Net VSC destroy send buffer
*/
static int
hv_nv_destroy_send_buffer(struct hn_softc *sc)
hn_nvs_disconn_chim(struct hn_softc *sc)
{
int ret = 0;
int error;
if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) {
struct hn_nvs_chim_disconn disconn;
@ -390,25 +383,25 @@ hv_nv_destroy_send_buffer(struct hn_softc *sc)
disconn.nvs_sig = HN_NVS_CHIM_SIG;
/* NOTE: No response. */
ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn));
if (ret != 0) {
error = hn_nvs_req_send(sc, &disconn, sizeof(disconn));
if (error) {
if_printf(sc->hn_ifp,
"send chim disconn failed: %d\n", ret);
return (ret);
"send nvs chim disconn failed: %d\n", error);
return (error);
}
sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED;
}
if (sc->hn_chim_gpadl != 0) {
/*
* Disconnect chimney sending buffer from primary channel.
*/
ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan,
error = vmbus_chan_gpadl_disconnect(sc->hn_prichan,
sc->hn_chim_gpadl);
if (ret != 0) {
if (error) {
if_printf(sc->hn_ifp,
"chim disconn failed: %d\n", ret);
return (ret);
"chim gpadl disconn failed: %d\n", error);
return (error);
}
sc->hn_chim_gpadl = 0;
}
@ -417,8 +410,7 @@ hv_nv_destroy_send_buffer(struct hn_softc *sc)
free(sc->hn_chim_bmap, M_NETVSC);
sc->hn_chim_bmap = NULL;
}
return (ret);
return (0);
}
static int
@ -567,7 +559,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu)
/*
* Connect chimney sending buffer.
*/
return hv_nv_init_send_buffer_with_net_vsp(sc);
return hn_nvs_conn_chim(sc);
}
/*
@ -577,7 +569,7 @@ static void
hv_nv_disconnect_from_vsp(struct hn_softc *sc)
{
hn_nvs_disconn_rxbuf(sc);
hv_nv_destroy_send_buffer(sc);
hn_nvs_disconn_chim(sc);
}
/*