Re: svn commit: r209611 - head/sys/dev/e1000

2010-06-30 Thread Jack Vogel
On Wed, Jun 30, 2010 at 2:50 PM, Julian Elischer wrote:

> On 6/30/10 10:26 AM, Jack F Vogel wrote:
>
>> Author: jfv
>> Date: Wed Jun 30 17:26:47 2010
>> New Revision: 209611
>> URL: http://svn.freebsd.org/changeset/base/209611
>>
>> Log:
>>   SR-IOV support added to igb
>>
>>   What this provides is support for the 'virtual function'
>>   interface that a FreeBSD VM may be assigned from a host
>>   like KVM on Linux, or newer versions of Xen with such
>>   support.
>>
>>   When the guest is set up with the capability, a special
>>   limited function 82576 PCI device is present in its virtual
>>   PCI space, so with this driver installed in the guest that
>>   device will be detected and function nearly like the bare
>>   metal, as it were.
>>
>>   The interface is only allowed a single queue in this configuration
>>   however initial performance tests have looked very good.
>>
>>   Enjoy!!
>>
>>
> do these extra devices turn up in a standard ifconfig output?
> in other words, can we assign them to jails using vimage?
>
>
They only show up if configured in the PF host, for instance if using Linux
and KVM (I did develop and test
with Fedora 13) you must load the igb driver there specifying that you want
vf's created and how many.
Next in the management of the guest you need to assign one of these vf
devices to the guest. After you
do all that and load this igb driver then yes, it will look just like a
standard igbX device.

Not sure if I understand your question, did any of that help? If you mean
can FreeBSD make
multiple VF's and then manage them with jails, no, that would be to have PF
support, and to
do that I need SRIOV support in the kernel/pci subsystem.

Now, if someone were interested in actually doing that then I'd be happy to
implement the full
PF/VF capability the way Linux has, but that's a bigger lift. Just let me
know if we want to
go in that direction.

Jack
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r209611 - head/sys/dev/e1000

2010-06-30 Thread Julian Elischer

On 6/30/10 10:26 AM, Jack F Vogel wrote:

Author: jfv
Date: Wed Jun 30 17:26:47 2010
New Revision: 209611
URL: http://svn.freebsd.org/changeset/base/209611

Log:
   SR-IOV support added to igb

   What this provides is support for the 'virtual function'
   interface that a FreeBSD VM may be assigned from a host
   like KVM on Linux, or newer versions of Xen with such
   support.

   When the guest is set up with the capability, a special
   limited function 82576 PCI device is present in its virtual
   PCI space, so with this driver installed in the guest that
   device will be detected and function nearly like the bare
   metal, as it were.

   The interface is only allowed a single queue in this configuration
   however initial performance tests have looked very good.

   Enjoy!!



do these extra devices turn up in a standard ifconfig output?
in other words, can we assign them to jails using vimage?

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r209611 - head/sys/dev/e1000

2010-06-30 Thread Jack Vogel
Yes, work is in progress to add it to ixgbe as well, it turned out to be a
bit messier
because the owners of the shared code did things a bit differently. I am
still designing
it so that its just a special case in the main driver, this is different
than Linux which made
both of them as seperate 'vf' driver.  Of course in Linux they actually have
the host side
support, ala PF, if the day ever comes that FreeBSD has such ability maybe
I'll have to
change it again... but not holding my breath.

I'd say the ixgbe changes might be ready in a few weeks.

Jack


On Wed, Jun 30, 2010 at 1:37 PM, Fabien Thomas wrote:

> great!
> have you some plan to do it on ixgbe too ?
>
> fabien
>
> On 30 juin 2010, at 19:26, Jack F Vogel wrote:
>
> > Author: jfv
> > Date: Wed Jun 30 17:26:47 2010
> > New Revision: 209611
> > URL: http://svn.freebsd.org/changeset/base/209611
> >
> > Log:
> >  SR-IOV support added to igb
> >
> >  What this provides is support for the 'virtual function'
> >  interface that a FreeBSD VM may be assigned from a host
> >  like KVM on Linux, or newer versions of Xen with such
> >  support.
> >
> >  When the guest is set up with the capability, a special
> >  limited function 82576 PCI device is present in its virtual
> >  PCI space, so with this driver installed in the guest that
> >  device will be detected and function nearly like the bare
> >  metal, as it were.
> >
> >  The interface is only allowed a single queue in this configuration
> >  however initial performance tests have looked very good.
> >
> >  Enjoy!!
> >
> > Modified:
> >  head/sys/dev/e1000/if_igb.c
> >  head/sys/dev/e1000/if_igb.h
> >
> > Modified: head/sys/dev/e1000/if_igb.c
> >
> ==
> > --- head/sys/dev/e1000/if_igb.c   Wed Jun 30 17:20:33 2010
>  (r209610)
> > +++ head/sys/dev/e1000/if_igb.c   Wed Jun 30 17:26:47 2010
>  (r209611)
> > @@ -99,7 +99,7 @@ int igb_display_debug_stats = 0;
> > /*
> >  *  Driver version:
> >  */
> > -char igb_driver_version[] = "version - 1.9.6";
> > +char igb_driver_version[] = "version - 2.0.1";
> >
> >
> > /*
> > @@ -128,6 +128,7 @@ static igb_vendor_info_t igb_vendor_info
> >   PCI_ANY_ID, PCI_ANY_ID, 0},
> >   { 0x8086, E1000_DEV_ID_82576_QUAD_COPPER,
> >   PCI_ANY_ID, PCI_ANY_ID, 0},
> > + { 0x8086, E1000_DEV_ID_82576_VF,PCI_ANY_ID, PCI_ANY_ID, 0},
> >   { 0x8086, E1000_DEV_ID_82580_COPPER,PCI_ANY_ID, PCI_ANY_ID, 0},
> >   { 0x8086, E1000_DEV_ID_82580_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
> >   { 0x8086, E1000_DEV_ID_82580_SERDES,PCI_ANY_ID, PCI_ANY_ID, 0},
> > @@ -226,7 +227,11 @@ static void  igb_dma_free(struct adapter
> > static intigb_sysctl_nvm_info(SYSCTL_HANDLER_ARGS);
> > static void   igb_print_nvm_info(struct adapter *);
> > static intigb_is_valid_ether_addr(u8 *);
> > -static void igb_add_hw_stats(struct adapter *adapter);
> > +static void igb_add_hw_stats(struct adapter *);
> > +
> > +static void  igb_vf_init_stats(struct adapter *);
> > +static void  igb_update_vf_stats_counters(struct adapter *);
> > +
> > /* Management and WOL Support */
> > static void   igb_init_manageability(struct adapter *);
> > static void   igb_release_manageability(struct adapter *);
> > @@ -494,6 +499,17 @@ igb_attach(device_t dev)
> >   goto err_pci;
> >   }
> >
> > + /* Allocate the appropriate stats memory */
> > + if (adapter->hw.mac.type == e1000_vfadapt) {
> > + adapter->stats =
> > + (struct e1000_vf_stats *)malloc(sizeof \
> > + (struct e1000_vf_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
> > + igb_vf_init_stats(adapter);
> > + } else
> > + adapter->stats =
> > + (struct e1000_hw_stats *)malloc(sizeof \
> > + (struct e1000_hw_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
> > +
> >   /*
> >   ** Start from a known state, this is
> >   ** important in reading the nvm and
> > @@ -1788,30 +1804,39 @@ static void
> > igb_set_promisc(struct adapter *adapter)
> > {
> >   struct ifnet*ifp = adapter->ifp;
> > - uint32_treg_rctl;
> > + struct e1000_hw *hw = &adapter->hw;
> > + u32 reg;
> >
> > - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
> > + if (hw->mac.type == e1000_vfadapt) {
> > + e1000_promisc_set_vf(hw, e1000_promisc_enabled);
> > + return;
> > + }
> >
> > + reg = E1000_READ_REG(hw, E1000_RCTL);
> >   if (ifp->if_flags & IFF_PROMISC) {
> > - reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
> > - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, re

Re: svn commit: r209611 - head/sys/dev/e1000

2010-06-30 Thread Fabien Thomas
great!
have you some plan to do it on ixgbe too ?

fabien

On 30 juin 2010, at 19:26, Jack F Vogel wrote:

> Author: jfv
> Date: Wed Jun 30 17:26:47 2010
> New Revision: 209611
> URL: http://svn.freebsd.org/changeset/base/209611
> 
> Log:
>  SR-IOV support added to igb
> 
>  What this provides is support for the 'virtual function'
>  interface that a FreeBSD VM may be assigned from a host
>  like KVM on Linux, or newer versions of Xen with such
>  support.
> 
>  When the guest is set up with the capability, a special
>  limited function 82576 PCI device is present in its virtual
>  PCI space, so with this driver installed in the guest that
>  device will be detected and function nearly like the bare
>  metal, as it were.
> 
>  The interface is only allowed a single queue in this configuration
>  however initial performance tests have looked very good.
> 
>  Enjoy!!
> 
> Modified:
>  head/sys/dev/e1000/if_igb.c
>  head/sys/dev/e1000/if_igb.h
> 
> Modified: head/sys/dev/e1000/if_igb.c
> ==
> --- head/sys/dev/e1000/if_igb.c   Wed Jun 30 17:20:33 2010
> (r209610)
> +++ head/sys/dev/e1000/if_igb.c   Wed Jun 30 17:26:47 2010
> (r209611)
> @@ -99,7 +99,7 @@ int igb_display_debug_stats = 0;
> /*
>  *  Driver version:
>  */
> -char igb_driver_version[] = "version - 1.9.6";
> +char igb_driver_version[] = "version - 2.0.1";
> 
> 
> /*
> @@ -128,6 +128,7 @@ static igb_vendor_info_t igb_vendor_info
>   PCI_ANY_ID, PCI_ANY_ID, 0},
>   { 0x8086, E1000_DEV_ID_82576_QUAD_COPPER,
>   PCI_ANY_ID, PCI_ANY_ID, 0},
> + { 0x8086, E1000_DEV_ID_82576_VF,PCI_ANY_ID, PCI_ANY_ID, 0},
>   { 0x8086, E1000_DEV_ID_82580_COPPER,PCI_ANY_ID, PCI_ANY_ID, 0},
>   { 0x8086, E1000_DEV_ID_82580_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
>   { 0x8086, E1000_DEV_ID_82580_SERDES,PCI_ANY_ID, PCI_ANY_ID, 0},
> @@ -226,7 +227,11 @@ static void  igb_dma_free(struct adapter 
> static intigb_sysctl_nvm_info(SYSCTL_HANDLER_ARGS);
> static void   igb_print_nvm_info(struct adapter *);
> static intigb_is_valid_ether_addr(u8 *);
> -static void igb_add_hw_stats(struct adapter *adapter);
> +static void igb_add_hw_stats(struct adapter *);
> +
> +static void  igb_vf_init_stats(struct adapter *);
> +static void  igb_update_vf_stats_counters(struct adapter *);
> +
> /* Management and WOL Support */
> static void   igb_init_manageability(struct adapter *);
> static void   igb_release_manageability(struct adapter *);
> @@ -494,6 +499,17 @@ igb_attach(device_t dev)
>   goto err_pci;
>   }
> 
> + /* Allocate the appropriate stats memory */
> + if (adapter->hw.mac.type == e1000_vfadapt) {
> + adapter->stats =
> + (struct e1000_vf_stats *)malloc(sizeof \
> + (struct e1000_vf_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
> + igb_vf_init_stats(adapter);
> + } else
> + adapter->stats =
> + (struct e1000_hw_stats *)malloc(sizeof \
> + (struct e1000_hw_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
> +
>   /*
>   ** Start from a known state, this is
>   ** important in reading the nvm and
> @@ -1788,30 +1804,39 @@ static void
> igb_set_promisc(struct adapter *adapter)
> {
>   struct ifnet*ifp = adapter->ifp;
> - uint32_treg_rctl;
> + struct e1000_hw *hw = &adapter->hw;
> + u32 reg;
> 
> - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
> + if (hw->mac.type == e1000_vfadapt) {
> + e1000_promisc_set_vf(hw, e1000_promisc_enabled);
> + return;
> + }
> 
> + reg = E1000_READ_REG(hw, E1000_RCTL);
>   if (ifp->if_flags & IFF_PROMISC) {
> - reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
> - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
> + reg |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
> + E1000_WRITE_REG(hw, E1000_RCTL, reg);
>   } else if (ifp->if_flags & IFF_ALLMULTI) {
> - reg_rctl |= E1000_RCTL_MPE;
> - reg_rctl &= ~E1000_RCTL_UPE;
> - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
> + reg |= E1000_RCTL_MPE;
> + reg &= ~E1000_RCTL_UPE;
> + E1000_WRITE_REG(hw, E1000_RCTL, reg);
>   }
> }
> 
> static void
> igb_disable_promisc(struct adapter *adapter)
> {
> - uint32_treg_rctl;
> -
> - reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
> + struct e1000_hw *hw = &adapter->hw;
> + u32 reg;
> 
> - reg_rctl &=  (~E1000_RCTL_UPE);
> - reg_rctl &=  (~E1000_RCTL_MPE);

svn commit: r209611 - head/sys/dev/e1000

2010-06-30 Thread Jack F Vogel
Author: jfv
Date: Wed Jun 30 17:26:47 2010
New Revision: 209611
URL: http://svn.freebsd.org/changeset/base/209611

Log:
  SR-IOV support added to igb
  
  What this provides is support for the 'virtual function'
  interface that a FreeBSD VM may be assigned from a host
  like KVM on Linux, or newer versions of Xen with such
  support.
  
  When the guest is set up with the capability, a special
  limited function 82576 PCI device is present in its virtual
  PCI space, so with this driver installed in the guest that
  device will be detected and function nearly like the bare
  metal, as it were.
  
  The interface is only allowed a single queue in this configuration
  however initial performance tests have looked very good.
  
  Enjoy!!

Modified:
  head/sys/dev/e1000/if_igb.c
  head/sys/dev/e1000/if_igb.h

Modified: head/sys/dev/e1000/if_igb.c
==
--- head/sys/dev/e1000/if_igb.c Wed Jun 30 17:20:33 2010(r209610)
+++ head/sys/dev/e1000/if_igb.c Wed Jun 30 17:26:47 2010(r209611)
@@ -99,7 +99,7 @@ int   igb_display_debug_stats = 0;
 /*
  *  Driver version:
  */
-char igb_driver_version[] = "version - 1.9.6";
+char igb_driver_version[] = "version - 2.0.1";
 
 
 /*
@@ -128,6 +128,7 @@ static igb_vendor_info_t igb_vendor_info
PCI_ANY_ID, PCI_ANY_ID, 0},
{ 0x8086, E1000_DEV_ID_82576_QUAD_COPPER,
PCI_ANY_ID, PCI_ANY_ID, 0},
+   { 0x8086, E1000_DEV_ID_82576_VF,PCI_ANY_ID, PCI_ANY_ID, 0},
{ 0x8086, E1000_DEV_ID_82580_COPPER,PCI_ANY_ID, PCI_ANY_ID, 0},
{ 0x8086, E1000_DEV_ID_82580_FIBER, PCI_ANY_ID, PCI_ANY_ID, 0},
{ 0x8086, E1000_DEV_ID_82580_SERDES,PCI_ANY_ID, PCI_ANY_ID, 0},
@@ -226,7 +227,11 @@ static voidigb_dma_free(struct adapter 
 static int igb_sysctl_nvm_info(SYSCTL_HANDLER_ARGS);
 static voidigb_print_nvm_info(struct adapter *);
 static int igb_is_valid_ether_addr(u8 *);
-static void igb_add_hw_stats(struct adapter *adapter);
+static void igb_add_hw_stats(struct adapter *);
+
+static voidigb_vf_init_stats(struct adapter *);
+static voidigb_update_vf_stats_counters(struct adapter *);
+
 /* Management and WOL Support */
 static voidigb_init_manageability(struct adapter *);
 static voidigb_release_manageability(struct adapter *);
@@ -494,6 +499,17 @@ igb_attach(device_t dev)
goto err_pci;
}
 
+   /* Allocate the appropriate stats memory */
+   if (adapter->hw.mac.type == e1000_vfadapt) {
+   adapter->stats =
+   (struct e1000_vf_stats *)malloc(sizeof \
+   (struct e1000_vf_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
+   igb_vf_init_stats(adapter);
+   } else
+   adapter->stats =
+   (struct e1000_hw_stats *)malloc(sizeof \
+   (struct e1000_hw_stats), M_DEVBUF, M_NOWAIT | M_ZERO);
+
/*
** Start from a known state, this is
** important in reading the nvm and
@@ -1788,30 +1804,39 @@ static void
 igb_set_promisc(struct adapter *adapter)
 {
struct ifnet*ifp = adapter->ifp;
-   uint32_treg_rctl;
+   struct e1000_hw *hw = &adapter->hw;
+   u32 reg;
 
-   reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
+   if (hw->mac.type == e1000_vfadapt) {
+   e1000_promisc_set_vf(hw, e1000_promisc_enabled);
+   return;
+   }
 
+   reg = E1000_READ_REG(hw, E1000_RCTL);
if (ifp->if_flags & IFF_PROMISC) {
-   reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
-   E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
+   reg |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
+   E1000_WRITE_REG(hw, E1000_RCTL, reg);
} else if (ifp->if_flags & IFF_ALLMULTI) {
-   reg_rctl |= E1000_RCTL_MPE;
-   reg_rctl &= ~E1000_RCTL_UPE;
-   E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
+   reg |= E1000_RCTL_MPE;
+   reg &= ~E1000_RCTL_UPE;
+   E1000_WRITE_REG(hw, E1000_RCTL, reg);
}
 }
 
 static void
 igb_disable_promisc(struct adapter *adapter)
 {
-   uint32_treg_rctl;
-
-   reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
+   struct e1000_hw *hw = &adapter->hw;
+   u32 reg;
 
-   reg_rctl &=  (~E1000_RCTL_UPE);
-   reg_rctl &=  (~E1000_RCTL_MPE);
-   E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
+   if (hw->mac.type == e1000_vfadapt) {
+   e1000_promisc_set_vf(hw, e1000_promisc_disabled);
+   return;
+   }