Author: sephe
Date: Tue Aug  9 04:50:20 2016
New Revision: 303867
URL: https://svnweb.freebsd.org/changeset/base/303867

Log:
  hyperv/hn: Move gpa array out of netvsc_packet.
  
  Prepare to deprecate the netvsc_packet.
  
  MFC after:    1 week
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D7436

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Tue Aug  9 04:41:33 2016        
(r303866)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c     Tue Aug  9 04:50:20 2016        
(r303867)
@@ -799,7 +799,8 @@ hv_nv_on_send_completion(netvsc_dev *net
  * Returns 0 on success, non-zero on failure.
  */
 int
-hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt)
+hv_nv_on_send(struct vmbus_channel *chan,
+    netvsc_packet *pkt, struct vmbus_gpa *gpa, int gpa_cnt)
 {
        nvsp_msg send_msg;
        int ret;
@@ -818,8 +819,8 @@ hv_nv_on_send(struct vmbus_channel *chan
        send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size =
            pkt->send_buf_section_size;
 
-       if (pkt->gpa_cnt) {
-               ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt,
+       if (gpa_cnt) {
+               ret = vmbus_chan_send_sglist(chan, gpa, gpa_cnt,
                    &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt);
        } else {
                ret = vmbus_chan_send(chan,

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Tue Aug  9 04:41:33 2016        
(r303866)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h     Tue Aug  9 04:50:20 2016        
(r303867)
@@ -1137,8 +1137,6 @@ typedef struct netvsc_packet_ {
        void            *rndis_mesg;
        uint32_t        tot_data_buf_len;
        void            *data;
-       uint32_t        gpa_cnt;
-       struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE];
 } netvsc_packet;
 
 typedef struct {
@@ -1216,6 +1214,9 @@ struct hn_tx_ring {
        bus_dma_tag_t   hn_tx_data_dtag;
        uint64_t        hn_csum_assist;
 
+       int             hn_gpa_cnt;
+       struct vmbus_gpa hn_gpa[NETVSC_PACKET_MAXPAGE];
+
        u_long          hn_no_txdescs;
        u_long          hn_send_failed;
        u_long          hn_txdma_failed;
@@ -1275,7 +1276,8 @@ netvsc_dev *hv_nv_on_device_add(struct h
     void *additional_info, struct hn_rx_ring *rxr);
 int hv_nv_on_device_remove(struct hn_softc *sc,
     boolean_t destroy_channel);
-int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt);
+int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt,
+       struct vmbus_gpa *gpa, int gpa_cnt);
 int hv_nv_get_next_send_section(netvsc_dev *net_dev);
 void hv_nv_subchan_attach(struct vmbus_channel *chan,
     struct hn_rx_ring *rxr);

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Tue Aug  9 04:41:33 
2016        (r303866)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Tue Aug  9 04:50:20 
2016        (r303867)
@@ -993,7 +993,7 @@ hn_encap(struct hn_tx_ring *txr, struct 
                        packet->send_buf_section_idx = send_buf_section_idx;
                        packet->send_buf_section_size =
                            packet->tot_data_buf_len;
-                       packet->gpa_cnt = 0;
+                       txr->hn_gpa_cnt = 0;
                        txr->hn_tx_chimney++;
                        goto done;
                }
@@ -1019,19 +1019,19 @@ hn_encap(struct hn_tx_ring *txr, struct 
        }
        *m_head0 = m_head;
 
-       packet->gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS;
+       txr->hn_gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS;
 
        /* send packet with page buffer */
-       packet->gpa[0].gpa_page = atop(txd->rndis_msg_paddr);
-       packet->gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK;
-       packet->gpa[0].gpa_len = rndis_msg_size;
+       txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr);
+       txr->hn_gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK;
+       txr->hn_gpa[0].gpa_len = rndis_msg_size;
 
        /*
         * Fill the page buffers with mbuf info starting at index
         * HV_RF_NUM_TX_RESERVED_PAGE_BUFS.
         */
        for (i = 0; i < nsegs; ++i) {
-               struct vmbus_gpa *gpa = &packet->gpa[
+               struct vmbus_gpa *gpa = &txr->hn_gpa[
                    i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS];
 
                gpa->gpa_page = atop(segs[i].ds_addr);
@@ -1068,7 +1068,8 @@ again:
         * Make sure that txd is not freed before ETHER_BPF_MTAP.
         */
        hn_txdesc_hold(txd);
-       error = hv_nv_on_send(txr->hn_chan, &txd->netvsc_pkt);
+       error = hv_nv_on_send(txr->hn_chan, &txd->netvsc_pkt,
+           txr->hn_gpa, txr->hn_gpa_cnt);
        if (!error) {
                ETHER_BPF_MTAP(ifp, txd->m);
                if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c        Tue Aug  9 04:41:33 
2016        (r303866)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c        Tue Aug  9 04:50:20 
2016        (r303867)
@@ -238,33 +238,31 @@ static int
 hv_rf_send_request(rndis_device *device, rndis_request *request,
     uint32_t message_type)
 {
-       int ret;
        netvsc_packet *packet;
        netvsc_dev      *net_dev = device->net_dev;
        int send_buf_section_idx;
+       struct vmbus_gpa gpa[2];
+       int gpa_cnt;
 
        /* Set up the packet to send it */
        packet = &request->pkt;
        
        packet->is_data_pkt = FALSE;
        packet->tot_data_buf_len = request->request_msg.msg_len;
-       packet->gpa_cnt = 1;
 
-       packet->gpa[0].gpa_page =
-           hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT;
-       packet->gpa[0].gpa_len = request->request_msg.msg_len;
-       packet->gpa[0].gpa_ofs =
-           (unsigned long)&request->request_msg & (PAGE_SIZE - 1);
-
-       if (packet->gpa[0].gpa_ofs + packet->gpa[0].gpa_len > PAGE_SIZE) {
-               packet->gpa_cnt = 2;
-               packet->gpa[0].gpa_len = PAGE_SIZE - packet->gpa[0].gpa_ofs;
-               packet->gpa[1].gpa_page =
-                       hv_get_phys_addr((char*)&request->request_msg +
-                               packet->gpa[0].gpa_len) >> PAGE_SHIFT;
-               packet->gpa[1].gpa_ofs = 0;
-               packet->gpa[1].gpa_len = request->request_msg.msg_len -
-                   packet->gpa[0].gpa_len;
+       gpa_cnt = 1;
+       gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT;
+       gpa[0].gpa_len = request->request_msg.msg_len;
+       gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1);
+
+       if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) {
+               gpa_cnt = 2;
+               gpa[0].gpa_len = PAGE_SIZE - gpa[0].gpa_ofs;
+               gpa[1].gpa_page =
+                   hv_get_phys_addr((char*)&request->request_msg +
+                   gpa[0].gpa_len) >> PAGE_SHIFT;
+               gpa[1].gpa_ofs = 0;
+               gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len;
        }
 
        packet->compl.send.send_completion_context = request; /* packet */
@@ -286,7 +284,7 @@ hv_rf_send_request(rndis_device *device,
                        memcpy(dest, &request->request_msg, 
request->request_msg.msg_len);
                        packet->send_buf_section_idx = send_buf_section_idx;
                        packet->send_buf_section_size = 
packet->tot_data_buf_len;
-                       packet->gpa_cnt = 0;
+                       gpa_cnt = 0;
                        goto sendit;
                }
                /* Failed to allocate chimney send buffer; move on */
@@ -295,9 +293,8 @@ hv_rf_send_request(rndis_device *device,
        packet->send_buf_section_size = 0;
 
 sendit:
-       ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet);
-
-       return (ret);
+       return hv_nv_on_send(device->net_dev->sc->hn_prichan, packet,
+           gpa, gpa_cnt);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to