svn commit: r324518 - head/sys/dev/ixgbe

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Oct 11 05:55:52 2017
New Revision: 324518
URL: https://svnweb.freebsd.org/changeset/base/324518

Log:
  ixgbe: Remove never defined UDP_IPV4_EX
  
  Reviewed by:  sbruno
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D12454

Modified:
  head/sys/dev/ixgbe/if_ix.c
  head/sys/dev/ixgbe/if_ixv.c
  head/sys/dev/ixgbe/ixgbe_rss.h

Modified: head/sys/dev/ixgbe/if_ix.c
==
--- head/sys/dev/ixgbe/if_ix.c  Wed Oct 11 05:28:51 2017(r324517)
+++ head/sys/dev/ixgbe/if_ix.c  Wed Oct 11 05:55:52 2017(r324518)
@@ -469,9 +469,6 @@ ixgbe_initialize_rss_mapping(struct adapter *adapter)
mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP;
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
-   if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4_EX)
-   device_printf(adapter->dev, "%s: RSS_HASHTYPE_RSS_UDP_IPV4_EX 
defined, but not supported\n",
-   __func__);
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)

Modified: head/sys/dev/ixgbe/if_ixv.c
==
--- head/sys/dev/ixgbe/if_ixv.c Wed Oct 11 05:28:51 2017(r324517)
+++ head/sys/dev/ixgbe/if_ixv.c Wed Oct 11 05:55:52 2017(r324518)
@@ -1403,9 +1403,6 @@ ixv_initialize_rss_mapping(struct adapter *adapter)
__func__);
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
-   if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4_EX)
-   device_printf(adapter->dev, "%s: RSS_HASHTYPE_RSS_UDP_IPV4_EX 
defined, but not supported\n",
-   __func__);
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)

Modified: head/sys/dev/ixgbe/ixgbe_rss.h
==
--- head/sys/dev/ixgbe/ixgbe_rss.h  Wed Oct 11 05:28:51 2017
(r324517)
+++ head/sys/dev/ixgbe/ixgbe_rss.h  Wed Oct 11 05:55:52 2017
(r324518)
@@ -49,7 +49,6 @@
 #define RSS_HASHTYPE_RSS_IPV6_EX   (1 << 5)
 #define RSS_HASHTYPE_RSS_TCP_IPV6_EX   (1 << 6)
 #define RSS_HASHTYPE_RSS_UDP_IPV4  (1 << 7)
-#define RSS_HASHTYPE_RSS_UDP_IPV4_EX   (1 << 8)
 #define RSS_HASHTYPE_RSS_UDP_IPV6  (1 << 9)
 #define RSS_HASHTYPE_RSS_UDP_IPV6_EX   (1 << 10)
 
___
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"


svn commit: r324517 - head/sys/dev/hyperv/netvsc

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Oct 11 05:28:51 2017
New Revision: 324517
URL: https://svnweb.freebsd.org/changeset/base/324517

Log:
  hyperv/hn: Enable transparent VF by default.
  
  MFC after:3 days
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/netvsc/if_hn.c

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==
--- head/sys/dev/hyperv/netvsc/if_hn.c  Wed Oct 11 05:15:49 2017
(r324516)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Wed Oct 11 05:28:51 2017
(r324517)
@@ -584,7 +584,7 @@ SYSCTL_PROC(_hw_hn, OID_AUTO, vfmap, CTLFLAG_RD | CTLT
 0, 0, hn_vfmap_sysctl, "A", "VF mapping");
 
 /* Transparent VF */
-static int hn_xpnt_vf = 0;
+static int hn_xpnt_vf = 1;
 SYSCTL_INT(_hw_hn, OID_AUTO, vf_transparent, CTLFLAG_RDTUN,
 _xpnt_vf, 0, "Transparent VF mod");
 
___
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"


svn commit: r324516 - head/sys/dev/hyperv/netvsc

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Oct 11 05:15:49 2017
New Revision: 324516
URL: https://svnweb.freebsd.org/changeset/base/324516

Log:
  hyperv/hn: Workaround erroneous hash type observed on WS2016 for VF.
  
  The background was described in r324489.
  
  MFC after:3 days
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/netvsc/hn_rndis.c
  head/sys/dev/hyperv/netvsc/if_hn.c
  head/sys/dev/hyperv/netvsc/ndis.h

Modified: head/sys/dev/hyperv/netvsc/hn_rndis.c
==
--- head/sys/dev/hyperv/netvsc/hn_rndis.c   Wed Oct 11 05:07:37 2017
(r324515)
+++ head/sys/dev/hyperv/netvsc/hn_rndis.c   Wed Oct 11 05:15:49 2017
(r324516)
@@ -521,6 +521,10 @@ hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_c
/* Commit! */
sc->hn_rss_ind_size = indsz;
sc->hn_rss_hcap = hash_func | hash_types;
+   if (sc->hn_caps & HN_CAP_UDPHASH) {
+   /* UDP 4-tuple hash is unconditionally enabled. */
+   sc->hn_rss_hcap |= NDIS_HASH_UDP_IPV4_X;
+   }
*rxr_cnt0 = rxr_cnt;
return (0);
 }
@@ -760,8 +764,10 @@ hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags)
("NDIS 6.20+ is required, NDIS version 0x%08x", sc->hn_ndis_ver));
 
/* XXX only one can be specified through, popcnt? */
-   KASSERT((sc->hn_rss_hash & NDIS_HASH_FUNCTION_MASK), ("no hash func"));
-   KASSERT((sc->hn_rss_hash & NDIS_HASH_TYPE_MASK), ("no hash types"));
+   KASSERT((sc->hn_rss_hash & NDIS_HASH_FUNCTION_MASK),
+   ("no hash func %08x", sc->hn_rss_hash));
+   KASSERT((sc->hn_rss_hash & NDIS_HASH_STD),
+   ("no standard hash types %08x", sc->hn_rss_hash));
KASSERT(sc->hn_rss_ind_size > 0, ("no indirect table size"));
 
if (bootverbose) {
@@ -780,7 +786,8 @@ hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags)
prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2;
prm->ndis_hdr.ndis_size = rss_size;
prm->ndis_flags = flags;
-   prm->ndis_hash = sc->hn_rss_hash;
+   prm->ndis_hash = sc->hn_rss_hash &
+   (NDIS_HASH_FUNCTION_MASK | NDIS_HASH_STD);
prm->ndis_indsize = sizeof(rss->rss_ind[0]) * sc->hn_rss_ind_size;
prm->ndis_indoffset =
__offsetof(struct ndis_rssprm_toeplitz, rss_ind[0]);

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==
--- head/sys/dev/hyperv/netvsc/if_hn.c  Wed Oct 11 05:07:37 2017
(r324515)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Wed Oct 11 05:15:49 2017
(r324516)
@@ -1424,6 +1424,8 @@ hn_rss_type_fromndis(uint32_t rss_hash)
types |= RSS_TYPE_TCP_IPV6;
if (rss_hash & NDIS_HASH_TCP_IPV6_EX)
types |= RSS_TYPE_TCP_IPV6_EX;
+   if (rss_hash & NDIS_HASH_UDP_IPV4_X)
+   types |= RSS_TYPE_UDP_IPV4;
return (types);
 }
 
@@ -1432,9 +1434,8 @@ hn_rss_type_tondis(uint32_t types)
 {
uint32_t rss_hash = 0;
 
-   KASSERT((types &
-   (RSS_TYPE_UDP_IPV4 | RSS_TYPE_UDP_IPV6 | RSS_TYPE_UDP_IPV6_EX)) == 0,
-   ("UDP4, UDP6 and UDP6EX are not supported"));
+   KASSERT((types & (RSS_TYPE_UDP_IPV6 | RSS_TYPE_UDP_IPV6_EX)) == 0,
+   ("UDP6 and UDP6EX are not supported"));
 
if (types & RSS_TYPE_IPV4)
rss_hash |= NDIS_HASH_IPV4;
@@ -1448,6 +1449,8 @@ hn_rss_type_tondis(uint32_t types)
rss_hash |= NDIS_HASH_TCP_IPV6;
if (types & RSS_TYPE_TCP_IPV6_EX)
rss_hash |= NDIS_HASH_TCP_IPV6_EX;
+   if (types & RSS_TYPE_UDP_IPV4)
+   rss_hash |= NDIS_HASH_UDP_IPV4_X;
return (rss_hash);
 }
 
@@ -1546,6 +1549,13 @@ hn_vf_rss_fixup(struct hn_softc *sc, bool reconf)
 * NOTE:
 * We don't disable the hash type, but stop delivery the hash
 * value/type through mbufs on RX path.
+*
+* XXX If HN_CAP_UDPHASH is set in hn_caps, then UDP 4-tuple
+* hash is delivered with type of TCP_IPV4.  This means if
+* UDP_IPV4 is enabled, then TCP_IPV4 should be forced, at
+* least to hn_mbuf_hash.  However, given that _all_ of the
+* NICs implement TCP_IPV4, this will _not_ impose any issues
+* here.
 */
if ((my_types & RSS_TYPE_IPV4) &&
(diff_types & ifrh.ifrh_types &
@@ -3582,7 +3592,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int
, );
}
if (l3proto == ETHERTYPE_IP) {
-   if (l4proto == IPPROTO_UDP) {
+   if (l4proto == IPPROTO_UDP &&
+   (rxr->hn_mbuf_hash &
+NDIS_HASH_UDP_IPV4_X)) {
 

svn commit: r324512 - head/sys/sparc64/sparc64

2017-10-10 Thread Kurt Lidl
Author: lidl
Date: Wed Oct 11 03:50:44 2017
New Revision: 324512
URL: https://svnweb.freebsd.org/changeset/base/324512

Log:
  Don't use a non-zero argument for __builtin_frame_address
  
  Mirror the change made for powerpc64 in r323687.  With this
  change, gcc 6.4.0 can successfully compile and link a kernel
  that runs on sparc64.
  
  MFC after:2 weeks

Modified:
  head/sys/sparc64/sparc64/stack_machdep.c

Modified: head/sys/sparc64/sparc64/stack_machdep.c
==
--- head/sys/sparc64/sparc64/stack_machdep.cWed Oct 11 02:39:20 2017
(r324511)
+++ head/sys/sparc64/sparc64/stack_machdep.cWed Oct 11 03:50:44 2017
(r324512)
@@ -93,5 +93,5 @@ void
 stack_save(struct stack *st)
 {
 
-   stack_capture(st, (struct frame *)__builtin_frame_address(1));
+   stack_capture(st, (struct frame *)__builtin_frame_address(0));
 }
___
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"


svn commit: r324511 - head/contrib/binutils/bfd

2017-10-10 Thread Justin Hibbits
Author: jhibbits
Date: Wed Oct 11 02:39:20 2017
New Revision: 324511
URL: https://svnweb.freebsd.org/changeset/base/324511

Log:
  Do exception offset computations in 64 bits, not 32.
  
  This fixes clang-built binaries on a gcc powerpc64 world.  Gets us one step
  closer to a clang-built world.  The same change was made in later upstream
  binutils.
  
  Submitted by: rdivacky
  MFC after:2 weeks

Modified:
  head/contrib/binutils/bfd/elf-eh-frame.c

Modified: head/contrib/binutils/bfd/elf-eh-frame.c
==
--- head/contrib/binutils/bfd/elf-eh-frame.cWed Oct 11 00:31:54 2017
(r324510)
+++ head/contrib/binutils/bfd/elf-eh-frame.cWed Oct 11 02:39:20 2017
(r324511)
@@ -1344,7 +1344,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
 
val = read_value (abfd, buf, per_width,
  get_DW_EH_PE_signed (per_encoding));
-   val += ent->offset - ent->new_offset;
+   val += (bfd_vma)ent->offset - ent->new_offset;
val -= extra_string + extra_data;
write_value (abfd, buf, val, per_width);
action &= ~4;
@@ -1400,7 +1400,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
  }
  break;
case DW_EH_PE_pcrel:
- value += ent->offset - ent->new_offset;
+ value += (bfd_vma)ent->offset - ent->new_offset;
  address += sec->output_section->vma + ent->offset + 8;
  break;
}
@@ -1428,7 +1428,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
  if (value)
{
  if ((ent->lsda_encoding & 0xf0) == DW_EH_PE_pcrel)
-   value += ent->offset - ent->new_offset;
+   value += (bfd_vma)ent->offset - ent->new_offset;
  else if (ent->cie_inf->need_lsda_relative)
value -= (sec->output_section->vma + ent->new_offset + 8
  + ent->lsda_offset);
___
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"


svn commit: r324509 - head/share/man/man9

2017-10-10 Thread Ed Maste
Author: emaste
Date: Tue Oct 10 23:54:25 2017
New Revision: 324509
URL: https://svnweb.freebsd.org/changeset/base/324509

Log:
  sysctl.9: document CTLFLAG_CAPRD and CTLFLAG_CAPWR
  
  Reported by:  Shawn Webb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/man/man9/sysctl.9

Modified: head/share/man/man9/sysctl.9
==
--- head/share/man/man9/sysctl.9Tue Oct 10 22:21:05 2017
(r324508)
+++ head/share/man/man9/sysctl.9Tue Oct 10 23:54:25 2017
(r324509)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 13, 2016
+.Dd October 10, 2017
 .Dt SYSCTL 9
 .Os
 .Sh NAME
@@ -668,6 +668,10 @@ Additionally, any of the following optional flags may 
 .Bl -tag -width ".Dv CTLFLAG_ANYBODY"
 .It Dv CTLFLAG_ANYBODY
 Any user or process can write to this sysctl.
+.It Dv CTLFLAG_CAPRD
+A process in capability mode can read from this sysctl.
+.It Dv CTLFLAG_CAPWR
+A process in capability mode can write to this sysctl.
 .It Dv CTLFLAG_SECURE
 This sysctl can be written to only if the effective securelevel of the
 process is \[<=] 0.
___
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"


svn commit: r324508 - head/sys/kern

2017-10-10 Thread Sean Bruno
Author: sbruno
Date: Tue Oct 10 22:21:05 2017
New Revision: 324508
URL: https://svnweb.freebsd.org/changeset/base/324508

Log:
  match sendfile() error handling to send().
  
  Sendfile() should match the error checking order of send() which
  is currently:
  
  SBS_CANTSENDMORE
  so_error
  SS_ISCONNECTED
  
  Submitted by: Jason Eggleston 
  Reviewed by:  glebius
  MFC after:2 weeks
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D12633

Modified:
  head/sys/kern/kern_sendfile.c

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Tue Oct 10 21:16:07 2017
(r324507)
+++ head/sys/kern/kern_sendfile.c   Tue Oct 10 22:21:05 2017
(r324508)
@@ -507,8 +507,6 @@ sendfile_getsock(struct thread *td, int s, struct file
*so = (*sock_fp)->f_data;
if ((*so)->so_type != SOCK_STREAM)
return (EINVAL);
-   if (((*so)->so_state & SS_ISCONNECTED) == 0)
-   return (ENOTCONN);
return (0);
 }
 
@@ -617,6 +615,12 @@ retry_space:
SOCKBUF_UNLOCK(>so_snd);
goto done;
}
+   if ((so->so_state & SS_ISCONNECTED) == 0) {
+   SOCKBUF_UNLOCK(>so_snd);
+   error = ENOTCONN;
+   goto done;
+   }
+
space = sbspace(>so_snd);
if (space < rem &&
(space <= 0 ||
___
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"


svn commit: r324507 - head/sbin/growfs

2017-10-10 Thread Ed Maste
Author: emaste
Date: Tue Oct 10 21:16:07 2017
New Revision: 324507
URL: https://svnweb.freebsd.org/changeset/base/324507

Log:
  growfs: ANSIfy cgckhash()
  
  The build was broken on GCC-using architectures with:
  
  growfs.c: In function 'cgckhash':
  growfs.c:1753: warning: old-style function definition
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sbin/growfs/growfs.c

Modified: head/sbin/growfs/growfs.c
==
--- head/sbin/growfs/growfs.c   Tue Oct 10 21:05:40 2017(r324506)
+++ head/sbin/growfs/growfs.c   Tue Oct 10 21:16:07 2017(r324507)
@@ -1748,8 +1748,7 @@ mount_reload(const struct statfs *stfs)
  * Calculate the check-hash of the cylinder group.
  */
 static void
-cgckhash(cgp)
-   struct cg *cgp;
+cgckhash(struct cg *cgp)
 {
 
if ((sblock.fs_metackhash & CK_CYLGRP) == 0)
___
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"


svn commit: r324506 - head/sys/fs/nfs

2017-10-10 Thread Rick Macklem
Author: rmacklem
Date: Tue Oct 10 21:05:40 2017
New Revision: 324506
URL: https://svnweb.freebsd.org/changeset/base/324506

Log:
  Fix forced dismount when a pNFS mount is hung on a DS.
  
  When a "pnfs" NFSv4.1 mount is hung because of an unresponsive DS,
  a forced dismount wouldn't work, because the RPC socket for the DS
  was not being closed. This patch fixes this.
  This will only affect "pnfs" mounts where the pNFS server's DS
  is unresponsive (crashed or network partitioned or...).
  Found during testing of the pNFS server.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfs/nfs_commonkrpc.c
  head/sys/fs/nfs/nfsclstate.h

Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==
--- head/sys/fs/nfs/nfs_commonkrpc.cTue Oct 10 21:04:40 2017
(r324505)
+++ head/sys/fs/nfs/nfs_commonkrpc.cTue Oct 10 21:05:40 2017
(r324506)
@@ -1121,9 +1121,29 @@ nfsmout:
 int
 newnfs_nmcancelreqs(struct nfsmount *nmp)
 {
+   struct nfsclds *dsp;
+   struct __rpc_client *cl;
 
if (nmp->nm_sockreq.nr_client != NULL)
CLNT_CLOSE(nmp->nm_sockreq.nr_client);
+lookformore:
+   NFSLOCKMNT(nmp);
+   TAILQ_FOREACH(dsp, >nm_sess, nfsclds_list) {
+   NFSLOCKDS(dsp);
+   if (dsp != TAILQ_FIRST(>nm_sess) &&
+   (dsp->nfsclds_flags & NFSCLDS_CLOSED) == 0 &&
+   dsp->nfsclds_sockp != NULL &&
+   dsp->nfsclds_sockp->nr_client != NULL) {
+   dsp->nfsclds_flags |= NFSCLDS_CLOSED;
+   cl = dsp->nfsclds_sockp->nr_client;
+   NFSUNLOCKDS(dsp);
+   NFSUNLOCKMNT(nmp);
+   CLNT_CLOSE(cl);
+   goto lookformore;
+   }
+   NFSUNLOCKDS(dsp);
+   }
+   NFSUNLOCKMNT(nmp);
return (0);
 }
 

Modified: head/sys/fs/nfs/nfsclstate.h
==
--- head/sys/fs/nfs/nfsclstate.hTue Oct 10 21:04:40 2017
(r324505)
+++ head/sys/fs/nfs/nfsclstate.hTue Oct 10 21:05:40 2017
(r324506)
@@ -91,6 +91,7 @@ struct nfsclds {
 #defineNFSCLDS_HASWRITEVERF0x0001
 #defineNFSCLDS_MDS 0x0002
 #defineNFSCLDS_DS  0x0004
+#defineNFSCLDS_CLOSED  0x0008
 
 struct nfsclclient {
LIST_ENTRY(nfsclclient) nfsc_list;
___
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"


svn commit: r324504 - head/sys/dev/qlxgbe

2017-10-10 Thread David C Somayajulu
Author: davidcs
Date: Tue Oct 10 20:45:45 2017
New Revision: 324504
URL: https://svnweb.freebsd.org/changeset/base/324504

Log:
  Revert Commit r324290
Add sanity checks in ql_hw_send() qla_send() to ensure that empty slots
in Tx Ring map to empty slot in Tx_buf array before Transmits. If the
checks fail further Transmission on that Tx Ring is prevented.

Modified:
  head/sys/dev/qlxgbe/ql_hw.c
  head/sys/dev/qlxgbe/ql_os.c

Modified: head/sys/dev/qlxgbe/ql_hw.c
==
--- head/sys/dev/qlxgbe/ql_hw.c Tue Oct 10 20:08:30 2017(r324503)
+++ head/sys/dev/qlxgbe/ql_hw.c Tue Oct 10 20:45:45 2017(r324504)
@@ -2374,16 +2374,6 @@ ql_hw_send(qla_host_t *ha, bus_dma_segment_t *segs, in
}
}
 
-   for (i = 0; i < num_tx_cmds; i++) {
-   if (NULL != ha->tx_ring[txr_idx].tx_buf[(tx_idx+i)].m_head) {
-   QL_ASSERT(ha, 0, \
-   ("%s: txr_idx = %d tx_idx = %d mbuf = %p\n",\
-   __func__, txr_idx, (tx_idx+i),\
-   
ha->tx_ring[txr_idx].tx_buf[(tx_idx+i)].m_head));
-   return (EINVAL);
-   }
-   }
-
tx_cmd = >tx_cntxt[txr_idx].tx_ring_base[tx_idx];
 
 if (!(mp->m_pkthdr.csum_flags & CSUM_TSO)) {

Modified: head/sys/dev/qlxgbe/ql_os.c
==
--- head/sys/dev/qlxgbe/ql_os.c Tue Oct 10 20:08:30 2017(r324503)
+++ head/sys/dev/qlxgbe/ql_os.c Tue Oct 10 20:45:45 2017(r324504)
@@ -1232,17 +1232,6 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp, uint32
QL_DPRINT8(ha, (ha->pci_dev, "%s: enter\n", __func__));
 
tx_idx = ha->hw.tx_cntxt[txr_idx].txr_next;
-
-   if (NULL != ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head) {
-   QL_ASSERT(ha, 0, ("%s: txr_idx = %d tx_idx = %d mbuf = %p\n",\
-   __func__, txr_idx, tx_idx,\
-   ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head));
-   if (m_head)
-   m_freem(m_head);
-   *m_headp = NULL;
-   return (ret);
-   }
-
map = ha->tx_ring[txr_idx].tx_buf[tx_idx].map;
 
ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, ,
___
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"


svn commit: r324503 - head/sys/dev/uart

2017-10-10 Thread Ed Maste
Author: emaste
Date: Tue Oct 10 20:08:30 2017
New Revision: 324503
URL: https://svnweb.freebsd.org/changeset/base/324503

Log:
  uart: detect 256-byte FIFOs
  
  Submitted by: Zakary Nafziger 
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/uart/uart_dev_ns8250.c

Modified: head/sys/dev/uart/uart_dev_ns8250.c
==
--- head/sys/dev/uart/uart_dev_ns8250.c Tue Oct 10 19:33:24 2017
(r324502)
+++ head/sys/dev/uart/uart_dev_ns8250.c Tue Oct 10 20:08:30 2017
(r324503)
@@ -873,7 +873,7 @@ ns8250_bus_probe(struct uart_softc *sc)
count = 0;
goto describe;
}
-   } while ((lsr & LSR_OE) == 0 && count < 130);
+   } while ((lsr & LSR_OE) == 0 && count < 260);
count--;
 
uart_setreg(bas, REG_MCR, mcr);
@@ -894,6 +894,9 @@ ns8250_bus_probe(struct uart_softc *sc)
} else if (count >= 112 && count <= 128) {
sc->sc_rxfifosz = 128;
device_set_desc(sc->sc_dev, "16950 or compatible");
+   } else if (count >= 224 && count <= 256) {
+   sc->sc_rxfifosz = 256;
+   device_set_desc(sc->sc_dev, "16x50 with 256 byte FIFO");
} else {
sc->sc_rxfifosz = 16;
device_set_desc(sc->sc_dev,
___
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"


svn commit: r324502 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/dispatcher sys/contrib/dev/acpica/components/ha...

2017-10-10 Thread Jung-uk Kim
Author: jkim
Date: Tue Oct 10 19:33:24 2017
New Revision: 324502
URL: https://svnweb.freebsd.org/changeset/base/324502

Log:
  Merge ACPICA 20170929 (take 2).

Added:
  head/sys/contrib/dev/acpica/compiler/aslallocate.c   (contents, props changed)
 - copied, changed from r324104, 
vendor-sys/acpica/dist/source/compiler/aslallocate.c
  head/sys/contrib/dev/acpica/compiler/aslcache.c   (contents, props changed)
 - copied, changed from r324104, 
vendor-sys/acpica/dist/source/compiler/aslcache.c
Modified:
  head/sys/contrib/dev/acpica/changes.txt
  head/sys/contrib/dev/acpica/common/adfile.c
  head/sys/contrib/dev/acpica/common/ahtable.c
  head/sys/contrib/dev/acpica/common/dmtable.c
  head/sys/contrib/dev/acpica/common/dmtbdump.c
  head/sys/contrib/dev/acpica/common/dmtbinfo.c
  head/sys/contrib/dev/acpica/compiler/aslcompile.c
  head/sys/contrib/dev/acpica/compiler/aslcompiler.h
  head/sys/contrib/dev/acpica/compiler/aslcompiler.l
  head/sys/contrib/dev/acpica/compiler/asldebug.c
  head/sys/contrib/dev/acpica/compiler/aslerror.c
  head/sys/contrib/dev/acpica/compiler/aslfiles.c
  head/sys/contrib/dev/acpica/compiler/aslhelp.c
  head/sys/contrib/dev/acpica/compiler/aslload.c
  head/sys/contrib/dev/acpica/compiler/aslmapenter.c
  head/sys/contrib/dev/acpica/compiler/aslmaputils.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.h
  head/sys/contrib/dev/acpica/compiler/aslmethod.c
  head/sys/contrib/dev/acpica/compiler/asloperands.c
  head/sys/contrib/dev/acpica/compiler/aslopt.c
  head/sys/contrib/dev/acpica/compiler/asloptions.c
  head/sys/contrib/dev/acpica/compiler/aslparseop.c
  head/sys/contrib/dev/acpica/compiler/aslprintf.c
  head/sys/contrib/dev/acpica/compiler/aslstartup.c
  head/sys/contrib/dev/acpica/compiler/aslsupport.l
  head/sys/contrib/dev/acpica/compiler/asltypes.h
  head/sys/contrib/dev/acpica/compiler/aslutils.c
  head/sys/contrib/dev/acpica/compiler/cvcompiler.c
  head/sys/contrib/dev/acpica/compiler/cvparser.c
  head/sys/contrib/dev/acpica/compiler/dtcompile.c
  head/sys/contrib/dev/acpica/compiler/dtcompiler.h
  head/sys/contrib/dev/acpica/compiler/dtexpress.c
  head/sys/contrib/dev/acpica/compiler/dtfield.c
  head/sys/contrib/dev/acpica/compiler/dtio.c
  head/sys/contrib/dev/acpica/compiler/dtparser.y
  head/sys/contrib/dev/acpica/compiler/dtsubtable.c
  head/sys/contrib/dev/acpica/compiler/dttable.c
  head/sys/contrib/dev/acpica/compiler/dttable1.c
  head/sys/contrib/dev/acpica/compiler/dttable2.c
  head/sys/contrib/dev/acpica/compiler/dttemplate.c
  head/sys/contrib/dev/acpica/compiler/dttemplate.h
  head/sys/contrib/dev/acpica/compiler/dtutils.c
  head/sys/contrib/dev/acpica/compiler/prexpress.c
  head/sys/contrib/dev/acpica/compiler/prmacros.c
  head/sys/contrib/dev/acpica/compiler/prparser.y
  head/sys/contrib/dev/acpica/compiler/prscan.c
  head/sys/contrib/dev/acpica/compiler/prutils.c
  head/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c
  head/sys/contrib/dev/acpica/components/hardware/hwtimer.c
  head/sys/contrib/dev/acpica/components/namespace/nsaccess.c
  head/sys/contrib/dev/acpica/components/namespace/nssearch.c
  head/sys/contrib/dev/acpica/components/parser/psobject.c
  head/sys/contrib/dev/acpica/components/parser/psutils.c
  head/sys/contrib/dev/acpica/components/utilities/utinit.c
  head/sys/contrib/dev/acpica/components/utilities/utmath.c
  head/sys/contrib/dev/acpica/include/acapps.h
  head/sys/contrib/dev/acpica/include/acconfig.h
  head/sys/contrib/dev/acpica/include/acdisasm.h
  head/sys/contrib/dev/acpica/include/acexcep.h
  head/sys/contrib/dev/acpica/include/aclocal.h
  head/sys/contrib/dev/acpica/include/acpixf.h
  head/sys/contrib/dev/acpica/include/actbl1.h
  head/sys/contrib/dev/acpica/include/actbl2.h
  head/sys/contrib/dev/acpica/include/actypes.h
  head/sys/dev/acpica/acpi_cpu.c
  head/usr.sbin/acpi/iasl/Makefile

Modified: head/sys/contrib/dev/acpica/changes.txt
==
--- head/sys/contrib/dev/acpica/changes.txt Tue Oct 10 19:20:38 2017
(r324501)
+++ head/sys/contrib/dev/acpica/changes.txt Tue Oct 10 19:33:24 2017
(r324502)
@@ -1,4 +1,104 @@
 
+29 September 2017. Summary of changes for version 20170929:
+
+
+1) ACPICA kernel-resident subsystem:
+
+Redesigned and implemented an improved ASL While() loop timeout 
+mechanism. This mechanism is used to prevent infinite loops in the kernel 
+AML interpreter caused by either non-responsive hardware or incorrect AML 
+code. The new implementation uses AcpiOsGetTimer instead of a simple 
+maximum loop count, and is thus more accurate and constant across 
+different machines. The default timeout is currently 30 seconds, but this 
+may be adjusted later.
+
+Renamed the ACPI_AML_INFINITE_LOOP exception to AE_AML_LOOP_TIMEOUT to 
+better reflect the new implementation of the loop timeout mechanism.
+
+Updated 

svn commit: r324501 - head/sys/dev/acpica/Osd

2017-10-10 Thread Jung-uk Kim
Author: jkim
Date: Tue Oct 10 19:20:38 2017
New Revision: 324501
URL: https://svnweb.freebsd.org/changeset/base/324501

Log:
  Do not check whether AcpiOsGetTimer() is called during boot.
  
  From ACPICA 20170929, AcpiOsGetTimer() should be available early because
  While() loop timeout mechanism was reimplemented with it.  Unfortunately,
  it means AcpiLoadTables() may cause panic when a While() loop is executed.
  After having lengthy discussions with ACPICA developers, I have concluded
  that dummy timecounter is good enough for the purpose and it is the least
  intrusive solution for now.  Also, they reminded me the ACPI specification
  implies OS timer function should be available before loading tables.

Modified:
  head/sys/dev/acpica/Osd/OsdSchedule.c

Modified: head/sys/dev/acpica/Osd/OsdSchedule.c
==
--- head/sys/dev/acpica/Osd/OsdSchedule.c   Tue Oct 10 19:14:40 2017
(r324500)
+++ head/sys/dev/acpica/Osd/OsdSchedule.c   Tue Oct 10 19:20:38 2017
(r324501)
@@ -274,9 +274,6 @@ AcpiOsGetTimer(void)
 struct bintime bt;
 UINT64 t;
 
-/* XXX During early boot there is no (decent) timer available yet. */
-KASSERT(cold == 0, ("acpi: timer op not yet supported during boot"));
-
 binuptime();
 t = (uint64_t)bt.sec * 1000;
 t += ((uint64_t)1000 * (uint32_t)(bt.frac >> 32)) >> 32;
___
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"


svn commit: r324500 - head/sys/modules/em

2017-10-10 Thread Sean Bruno
Author: sbruno
Date: Tue Oct 10 19:14:40 2017
New Revision: 324500
URL: https://svnweb.freebsd.org/changeset/base/324500

Log:
  Hard link if_igb.ko to if_em.ko.  Use a LINK directive to ensure that
  this is more friendly to the tree.
  
  Tested this with loader.conf:if_igb_load="YES" and it does the right
  thing.
  
  Submitted by: Ian Lepore 

Modified:
  head/sys/modules/em/Makefile

Modified: head/sys/modules/em/Makefile
==
--- head/sys/modules/em/MakefileTue Oct 10 16:17:03 2017
(r324499)
+++ head/sys/modules/em/MakefileTue Oct 10 19:14:40 2017
(r324500)
@@ -22,7 +22,6 @@ CFLAGS += -I${SRCTOP}/sys/dev/e1000
 # DEVICE_POLLING for a non-interrupt-driven method
 #CFLAGS  += -DDEVICE_POLLING
 
-afterinstall:
-   cd ${DESTDIR}${KMODDIR} && ln -sf if_em.ko if_igb.ko
+LINKS= ${KMODDIR}/${KMOD}.ko ${KMODDIR}/if_igb.ko
 
 .include 
___
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"


Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Andriy Gapon
On 10/10/2017 20:03, Ian Lepore wrote:
> This conversation is making me think harder about what's happening on
> the bus during the two different kinds of scans, and I'm realizing the
> answer is "almost exactly the same thing in both cases".
> 
> A "normal" scan is a START, followed by 9 clocks during which the slave
> address is put on the bus and either an ACK or NAK happens, followed by
> a STOP.
> 
> A new-style "read" scan is a START, followed by 9 clocks during which
> the slave address is put on the bus and either an ACK or NAK happens,
> followed by 9 more clocks for transferring a byte+NAK, followed by a
> STOP.
> 
> So the entire difference is 9 extra clocks, in terms of bus behavior.
>  Operationally, the slave device already indicated a willingness to
> service a read operation when it ACK'd its address following the start.
> 
> Actually doing the read shouldn't put the device into a bad state, but
> I guess we could theorize it might... maybe it likes to work in 16-bit
> chunks and a STOP after 8 bits confuses it.  But before the stop comes
> a NAK from the master which says "I don't want to read anymore" and if
> that confuses the device, it's violating the protocol.
> 
> All in all, I'm now wondering if what should change is removing the
> wording about the read-based scan being somehow "less reliable", I
> don't think it really is.

Well, the misbehaving devices most certainly violate the protocol, but that does
not change the fact that they exist.  For example, the PLL chip I mentioned
earlier simply listened for its slave address and then expected a fixed length
sequence of bytes to program a new frequency.  The slave even ignored the R/W
bit and intermediate start-stop bits.  It simply treated the next 8 x N bits as
the data.
I think that it was this chip or something like it:
http://pdf1.alldatasheet.com/datasheet-pdf/view/58355/CYPRESS/W48S111-14.html


-- 
Andriy Gapon
___
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"

Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Ian Lepore
On Tue, 2017-10-10 at 19:23 +0300, Andriy Gapon wrote:
> On 10/10/2017 19:12, Ian Lepore wrote:
> > 
> > On Tue, 2017-10-10 at 17:45 +0300, Andriy Gapon wrote:
> > > 
> > > On 12/09/2017 00:49, Ian Lepore wrote:
> > > > 
> > > > 
> > > > Author: ian
> > > > Date: Mon Sep 11 21:49:38 2017
> > > > New Revision: 323465
> > > > URL: https://svnweb.freebsd.org/changeset/base/323465
> > > > 
> > > > Log:
> > > >   Make i2c -s (device scan) work on hardware that supports only full 
> > > > xfers.
> > > >   
> > > >   The existing scan code is based on sending an i2c START condition and 
> > > > if
> > > >   there is no error it assumes there is a device at that i2c address.  
> > > > Some
> > > >   i2c controllers don't support sending individual start/stop signals 
> > > > on the
> > > >   bus, they can only perform complete data transfers with start/stop 
> > > > handled
> > > >   in the silicon.
> > > >   
> > > >   This adds a fallback mechanism that attempts to read a single byte 
> > > > from each
> > > >   i2c address.  It's less reliable than looking for an an ACK repsonse 
> > > > to a
> > > >   start, because some devices will NAK an attempt to read that isn't 
> > > > preceeded
> > > >   by a write of a register address.  Writing to devices to probe them 
> > > > is too
> > > >   dangerous to even consider.  The user is told that a less-reliable 
> > > > scan is
> > > >   being done, so even if the read-scan comes up empty too, it's still a 
> > > > vast
> > > >   improvement over the old situation where it would just claim there 
> > > > were no
> > > >   devices on the bus even though the devices were there and working 
> > > > fine.
> > > >   
> > > >   If the i2c controller responds with a proper ENODEV (device doesn't 
> > > > support
> > > >   operation) or an almost-proper EOPNOTSUPP, the START/STOP scan is 
> > > > switched
> > > >   to a read-scan right away.  Most controllers respond with ENXIO or 
> > > > EIO if
> > > >   they don't support START/STOP, so no quick-out is available.  For 
> > > > those,
> > > >   if a scan of all 127 addresses and come up empty, the scan is re-done 
> > > > using
> > > >   the read method.
> > > Perhaps the new scan method should have been added as a separate option 
> > > that has
> > > to be explicitly activated...  My concern is that there are some extremely
> > > simple I2C devices out there that do no sanity checking and may get 
> > > confused
> > > 
> > i2c -s is not a thing that's done routinely in a production system or
> > normal system operations... it's something a person does manually when
> > trying to configure or debug a system.
> Right.  And another point, it's not extremely hard to type another option on 
> the
> command line.  I haven't suggested that the functionality should not have been
> added at all, I have just suggested adding a new option to unlock it.
> 

This conversation is making me think harder about what's happening on
the bus during the two different kinds of scans, and I'm realizing the
answer is "almost exactly the same thing in both cases".

A "normal" scan is a START, followed by 9 clocks during which the slave
address is put on the bus and either an ACK or NAK happens, followed by
a STOP.

A new-style "read" scan is a START, followed by 9 clocks during which
the slave address is put on the bus and either an ACK or NAK happens,
followed by 9 more clocks for transferring a byte+NAK, followed by a
STOP.

So the entire difference is 9 extra clocks, in terms of bus behavior.
 Operationally, the slave device already indicated a willingness to
service a read operation when it ACK'd its address following the start.

Actually doing the read shouldn't put the device into a bad state, but
I guess we could theorize it might... maybe it likes to work in 16-bit
chunks and a STOP after 8 bits confuses it.  But before the stop comes
a NAK from the master which says "I don't want to read anymore" and if
that confuses the device, it's violating the protocol.

All in all, I'm now wondering if what should change is removing the
wording about the read-based scan being somehow "less reliable", I
don't think it really is.

-- Ian
___
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"


Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Andriy Gapon
On 10/10/2017 19:42, Ian Lepore wrote:
> On Tue, 2017-10-10 at 19:20 +0300, Andriy Gapon wrote:
>> On 10/10/2017 19:12, Ian Lepore wrote:
>>>
>>> i2c -s is not a thing that's done routinely in a production system or
>>> normal system operations... it's something a person does manually when
>>> trying to configure or debug a system.  In that situation, there is
>>> more harm in being told there are no working devices on the bus when in
>>> fact everything is fine, than there is some some hypothetical device
>>> doing some hypothetical "bad thing" in response to a read command.  In
>>> all my years of working with i2c stuff I've never seen a device doing
>>> anything more harmful than hanging the bus, requiring a reset (and even
>>> causing that requires worse behavior than an unexpected read).  On the
>>> other hand, I've seen a lot of people frustrated that i2c -s on freebsd
>>> says there are no devices, while the equivelent command on linux shows
>>> that everything is fine.
>> Okay.
>>
>> However, I will just mention that in the past I used to own a system where
>> scanning the bus would make a slave that controlled CPU frequency to change 
>> it
>> to some garbage.  The system "just" crashed, but theoretically the damage 
>> could
>> have been worse.
>> Also, I own a system right now where scanning the bus results in something 
>> like
>> what you mentioned, but a little bit worse, the hanging bus that can be 
>> brought
>> back only by a power cycle (not even a warm reset).
>>
> 
> These systems didn't used to hang on i2c -s, and now they do?

Sorry, I failed to clarify that I talked about smbus and smbmsg -p.
I imagine that pure i2c slaves can be as fragile.

-- 
Andriy Gapon
___
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"

Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Ian Lepore
On Tue, 2017-10-10 at 19:20 +0300, Andriy Gapon wrote:
> On 10/10/2017 19:12, Ian Lepore wrote:
> > 
> > i2c -s is not a thing that's done routinely in a production system or
> > normal system operations... it's something a person does manually when
> > trying to configure or debug a system.  In that situation, there is
> > more harm in being told there are no working devices on the bus when in
> > fact everything is fine, than there is some some hypothetical device
> > doing some hypothetical "bad thing" in response to a read command.  In
> > all my years of working with i2c stuff I've never seen a device doing
> > anything more harmful than hanging the bus, requiring a reset (and even
> > causing that requires worse behavior than an unexpected read).  On the
> > other hand, I've seen a lot of people frustrated that i2c -s on freebsd
> > says there are no devices, while the equivelent command on linux shows
> > that everything is fine.
> Okay.
> 
> However, I will just mention that in the past I used to own a system where
> scanning the bus would make a slave that controlled CPU frequency to change it
> to some garbage.  The system "just" crashed, but theoretically the damage 
> could
> have been worse.
> Also, I own a system right now where scanning the bus results in something 
> like
> what you mentioned, but a little bit worse, the hanging bus that can be 
> brought
> back only by a power cycle (not even a warm reset).
> 

These systems didn't used to hang on i2c -s, and now they do?

-- Ian
___
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"


Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Andriy Gapon
On 10/10/2017 19:12, Ian Lepore wrote:
> On Tue, 2017-10-10 at 17:45 +0300, Andriy Gapon wrote:
>> On 12/09/2017 00:49, Ian Lepore wrote:
>>>
>>> Author: ian
>>> Date: Mon Sep 11 21:49:38 2017
>>> New Revision: 323465
>>> URL: https://svnweb.freebsd.org/changeset/base/323465
>>>
>>> Log:
>>>   Make i2c -s (device scan) work on hardware that supports only full xfers.
>>>   
>>>   The existing scan code is based on sending an i2c START condition and if
>>>   there is no error it assumes there is a device at that i2c address.  Some
>>>   i2c controllers don't support sending individual start/stop signals on the
>>>   bus, they can only perform complete data transfers with start/stop handled
>>>   in the silicon.
>>>   
>>>   This adds a fallback mechanism that attempts to read a single byte from 
>>> each
>>>   i2c address.  It's less reliable than looking for an an ACK repsonse to a
>>>   start, because some devices will NAK an attempt to read that isn't 
>>> preceeded
>>>   by a write of a register address.  Writing to devices to probe them is too
>>>   dangerous to even consider.  The user is told that a less-reliable scan is
>>>   being done, so even if the read-scan comes up empty too, it's still a vast
>>>   improvement over the old situation where it would just claim there were no
>>>   devices on the bus even though the devices were there and working fine.
>>>   
>>>   If the i2c controller responds with a proper ENODEV (device doesn't 
>>> support
>>>   operation) or an almost-proper EOPNOTSUPP, the START/STOP scan is switched
>>>   to a read-scan right away.  Most controllers respond with ENXIO or EIO if
>>>   they don't support START/STOP, so no quick-out is available.  For those,
>>>   if a scan of all 127 addresses and come up empty, the scan is re-done 
>>> using
>>>   the read method.
>>
>> Perhaps the new scan method should have been added as a separate option that 
>> has
>> to be explicitly activated...  My concern is that there are some extremely
>> simple I2C devices out there that do no sanity checking and may get confused
>>
> 
> i2c -s is not a thing that's done routinely in a production system or
> normal system operations... it's something a person does manually when
> trying to configure or debug a system.

Right.  And another point, it's not extremely hard to type another option on the
command line.  I haven't suggested that the functionality should not have been
added at all, I have just suggested adding a new option to unlock it.

> In that situation, there is
> more harm in being told there are no working devices on the bus when in
> fact everything is fine, than there is some some hypothetical device
> doing some hypothetical "bad thing" in response to a read command.  In
> all my years of working with i2c stuff I've never seen a device doing
> anything more harmful than hanging the bus, requiring a reset (and even
> causing that requires worse behavior than an unexpected read).  On the
> other hand, I've seen a lot of people frustrated that i2c -s on freebsd
> says there are no devices, while the equivelent command on linux shows
> that everything is fine.


-- 
Andriy Gapon
___
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"

Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Andriy Gapon
On 10/10/2017 19:12, Ian Lepore wrote:
> i2c -s is not a thing that's done routinely in a production system or
> normal system operations... it's something a person does manually when
> trying to configure or debug a system.  In that situation, there is
> more harm in being told there are no working devices on the bus when in
> fact everything is fine, than there is some some hypothetical device
> doing some hypothetical "bad thing" in response to a read command.  In
> all my years of working with i2c stuff I've never seen a device doing
> anything more harmful than hanging the bus, requiring a reset (and even
> causing that requires worse behavior than an unexpected read).  On the
> other hand, I've seen a lot of people frustrated that i2c -s on freebsd
> says there are no devices, while the equivelent command on linux shows
> that everything is fine.

Okay.

However, I will just mention that in the past I used to own a system where
scanning the bus would make a slave that controlled CPU frequency to change it
to some garbage.  The system "just" crashed, but theoretically the damage could
have been worse.
Also, I own a system right now where scanning the bus results in something like
what you mentioned, but a little bit worse, the hanging bus that can be brought
back only by a power cycle (not even a warm reset).

-- 
Andriy Gapon
___
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"

svn commit: r324499 - head/sbin/growfs

2017-10-10 Thread Kirk McKusick
Author: mckusick
Date: Tue Oct 10 16:17:03 2017
New Revision: 324499
URL: https://svnweb.freebsd.org/changeset/base/324499

Log:
  Growfs got missed in r323923 that added a check hash to cylinder groups.
  This makes the needed changes to add/update cylinder group check hashes
  when a filesystem is expanded.
  
  Reported by: kib and Warner Losh (imp)
  Reviewed by: kib
  Tested by: Peter Holm (pho)

Modified:
  head/sbin/growfs/Makefile
  head/sbin/growfs/growfs.c

Modified: head/sbin/growfs/Makefile
==
--- head/sbin/growfs/Makefile   Tue Oct 10 15:46:58 2017(r324498)
+++ head/sbin/growfs/Makefile   Tue Oct 10 16:17:03 2017(r324499)
@@ -20,7 +20,7 @@ CFLAGS+= -DFS_DEBUG
 NO_WCAST_ALIGN= yes
 .endif
 
-LIBADD=util
+LIBADD=ufs util
 
 HAS_TESTS=
 SUBDIR.${MK_TESTS}+= tests

Modified: head/sbin/growfs/growfs.c
==
--- head/sbin/growfs/growfs.c   Tue Oct 10 15:46:58 2017(r324498)
+++ head/sbin/growfs/growfs.c   Tue Oct 10 16:17:03 2017(r324499)
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include "debug.h"
 
@@ -121,6 +122,7 @@ static void updcsloc(time_t, int, int, unsigned int);
 static voidfrag_adjust(ufs2_daddr_t, int);
 static voidupdclst(int);
 static voidmount_reload(const struct statfs *stfs);
+static voidcgckhash(struct cg *);
 
 /*
  * Here we actually start growing the file system. We basically read the
@@ -480,6 +482,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned in
sblock.fs_cstotal.cs_nifree += acg.cg_cs.cs_nifree;
*cs = acg.cg_cs;
 
+   cgckhash();
memcpy(iobuf, , sblock.fs_cgsize);
memset(iobuf + sblock.fs_cgsize, '\0',
sblock.fs_bsize * 3 - sblock.fs_cgsize);
@@ -771,6 +774,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, un
/*
 * Write the updated "joining" cylinder group back to disk.
 */
+   cgckhash();
wtfs(fsbtodb(, cgtod(, cylno)), (size_t)sblock.fs_cgsize,
(void *), fso, Nflag);
DBG_PRINT0("jcg written\n");
@@ -1738,4 +1742,18 @@ mount_reload(const struct statfs *stfs)
err(9, "%s: cannot reload filesystem%s%s", stfs->f_mntonname,
*errmsg != '\0' ? ": " : "", errmsg);
}
+}
+
+/*
+ * Calculate the check-hash of the cylinder group.
+ */
+static void
+cgckhash(cgp)
+   struct cg *cgp;
+{
+
+   if ((sblock.fs_metackhash & CK_CYLGRP) == 0)
+   return;
+   cgp->cg_ckhash = 0;
+   cgp->cg_ckhash = calculate_crc32c(~0L, (void *)cgp, sblock.fs_cgsize);
 }
___
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"


Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Ian Lepore
On Tue, 2017-10-10 at 17:45 +0300, Andriy Gapon wrote:
> On 12/09/2017 00:49, Ian Lepore wrote:
> > 
> > Author: ian
> > Date: Mon Sep 11 21:49:38 2017
> > New Revision: 323465
> > URL: https://svnweb.freebsd.org/changeset/base/323465
> > 
> > Log:
> >   Make i2c -s (device scan) work on hardware that supports only full xfers.
> >   
> >   The existing scan code is based on sending an i2c START condition and if
> >   there is no error it assumes there is a device at that i2c address.  Some
> >   i2c controllers don't support sending individual start/stop signals on the
> >   bus, they can only perform complete data transfers with start/stop handled
> >   in the silicon.
> >   
> >   This adds a fallback mechanism that attempts to read a single byte from 
> > each
> >   i2c address.  It's less reliable than looking for an an ACK repsonse to a
> >   start, because some devices will NAK an attempt to read that isn't 
> > preceeded
> >   by a write of a register address.  Writing to devices to probe them is too
> >   dangerous to even consider.  The user is told that a less-reliable scan is
> >   being done, so even if the read-scan comes up empty too, it's still a vast
> >   improvement over the old situation where it would just claim there were no
> >   devices on the bus even though the devices were there and working fine.
> >   
> >   If the i2c controller responds with a proper ENODEV (device doesn't 
> > support
> >   operation) or an almost-proper EOPNOTSUPP, the START/STOP scan is switched
> >   to a read-scan right away.  Most controllers respond with ENXIO or EIO if
> >   they don't support START/STOP, so no quick-out is available.  For those,
> >   if a scan of all 127 addresses and come up empty, the scan is re-done 
> > using
> >   the read method.
> 
> Perhaps the new scan method should have been added as a separate option that 
> has
> to be explicitly activated...  My concern is that there are some extremely
> simple I2C devices out there that do no sanity checking and may get confused
> 

i2c -s is not a thing that's done routinely in a production system or
normal system operations... it's something a person does manually when
trying to configure or debug a system.  In that situation, there is
more harm in being told there are no working devices on the bus when in
fact everything is fine, than there is some some hypothetical device
doing some hypothetical "bad thing" in response to a read command.  In
all my years of working with i2c stuff I've never seen a device doing
anything more harmful than hanging the bus, requiring a reset (and even
causing that requires worse behavior than an unexpected read).  On the
other hand, I've seen a lot of people frustrated that i2c -s on freebsd
says there are no devices, while the equivelent command on linux shows
that everything is fine.

-- Ian

___
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"


svn commit: r324497 - head/usr.bin/su

2017-10-10 Thread Ngie Cooper
Author: ngie
Date: Tue Oct 10 15:41:35 2017
New Revision: 324497
URL: https://svnweb.freebsd.org/changeset/base/324497

Log:
  Mute gcc warning about p not being possibly initialized
  
  I'm running into this warning on a tinderbox run with gcc 4.2.1 with mips and
  powerpc.
  
  MFC after:1 week

Modified:
  head/usr.bin/su/su.c

Modified: head/usr.bin/su/su.c
==
--- head/usr.bin/su/su.cTue Oct 10 13:06:11 2017(r324496)
+++ head/usr.bin/su/su.cTue Oct 10 15:41:35 2017(r324497)
@@ -172,7 +172,7 @@ main(int argc, char *argv[])
au_id_t  auid;
 #endif
 
-   shell = class = cleanenv = NULL;
+   p = shell = class = cleanenv = NULL;
asme = asthem = fastlogin = statusp = 0;
user = "root";
iscsh = UNSET;
___
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"


Re: svn commit: r324406 - head/sys/modules/em

2017-10-10 Thread Rodney W. Grimes
> 
> > On Oct 9, 2017, at 18:54, Ian Lepore  wrote:
> 
> ...
> 
> > I think the right answer here is just
> > 
> >   LINKS= ${KMODDIR}/${KMOD}.ko ${KMODDIR}/if_igb.ko
> 
>   That will definitely work and is probably the best pattern.
> Thanks,
> -Ngie

I concur, a hard link would probably be a better solution all
around than a symlink, unless there is some major reason
for this to be a symlink?


-- 
Rod Grimes rgri...@freebsd.org
___
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"


Re: svn commit: r323465 - head/usr.sbin/i2c

2017-10-10 Thread Andriy Gapon
On 12/09/2017 00:49, Ian Lepore wrote:
> Author: ian
> Date: Mon Sep 11 21:49:38 2017
> New Revision: 323465
> URL: https://svnweb.freebsd.org/changeset/base/323465
> 
> Log:
>   Make i2c -s (device scan) work on hardware that supports only full xfers.
>   
>   The existing scan code is based on sending an i2c START condition and if
>   there is no error it assumes there is a device at that i2c address.  Some
>   i2c controllers don't support sending individual start/stop signals on the
>   bus, they can only perform complete data transfers with start/stop handled
>   in the silicon.
>   
>   This adds a fallback mechanism that attempts to read a single byte from each
>   i2c address.  It's less reliable than looking for an an ACK repsonse to a
>   start, because some devices will NAK an attempt to read that isn't preceeded
>   by a write of a register address.  Writing to devices to probe them is too
>   dangerous to even consider.  The user is told that a less-reliable scan is
>   being done, so even if the read-scan comes up empty too, it's still a vast
>   improvement over the old situation where it would just claim there were no
>   devices on the bus even though the devices were there and working fine.
>   
>   If the i2c controller responds with a proper ENODEV (device doesn't support
>   operation) or an almost-proper EOPNOTSUPP, the START/STOP scan is switched
>   to a read-scan right away.  Most controllers respond with ENXIO or EIO if
>   they don't support START/STOP, so no quick-out is available.  For those,
>   if a scan of all 127 addresses and come up empty, the scan is re-done using
>   the read method.


Perhaps the new scan method should have been added as a separate option that has
to be explicitly activated...  My concern is that there are some extremely
simple I2C devices out there that do no sanity checking and may get confused

>   Reported by:Maxim Filimonov 
> 
> Modified:
>   head/usr.sbin/i2c/i2c.c
> 
> Modified: head/usr.sbin/i2c/i2c.c
> ==
> --- head/usr.sbin/i2c/i2c.c   Mon Sep 11 21:32:35 2017(r323464)
> +++ head/usr.sbin/i2c/i2c.c   Mon Sep 11 21:49:38 2017(r323465)
> @@ -121,9 +121,12 @@ skip_get_tokens(char *skip_addr, int *sk_addr, int max
>  static int
>  scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr)
>  {
> + struct iic_msg rdmsg;
> + struct iic_rdwr_data rdwrdata;
>   struct skip_range addr_range = { 0, 0 };
>   int *tokens, fd, error, i, index, j;
> - int len = 0, do_skip = 0, no_range = 1;
> + int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 
> 0;
> + uint8_t rdbyte;
>  
>   fd = open(dev, O_RDWR);
>   if (fd == -1) {
> @@ -157,6 +160,14 @@ scan_bus(struct iiccmd cmd, char *dev, int skip, char 
>   }
>  
>   printf("Scanning I2C devices on %s: ", dev);
> +
> +start_over:
> + if (use_read_xfer) {
> + fprintf(stderr, 
> + "Hardware may not support START/STOP scanning; "
> + "trying less-reliable read method.\n");
> + }
> +
>   for (i = 1; i < 127; i++) {
>  
>   if (skip && ( addr_range.start < addr_range.end)) {
> @@ -180,17 +191,46 @@ scan_bus(struct iiccmd cmd, char *dev, int skip, char 
>   cmd.last = 1;
>   cmd.count = 0;
>   error = ioctl(fd, I2CRSTCARD, );
> - if (error)
> + if (error) {
> + fprintf(stderr, "Controller reset failed\n");
>   goto out;
> -
> - cmd.slave = i << 1;
> - cmd.last = 1;
> - error = ioctl(fd, I2CSTART, );
> - if (!error)
> - printf("%x ", i);
> - cmd.slave = i << 1;
> - cmd.last = 1;
> - error = ioctl(fd, I2CSTOP, );
> + }
> + if (use_read_xfer) {
> + rdmsg.buf = 
> + rdmsg.len = 1;
> + rdmsg.flags = IIC_M_RD;
> + rdmsg.slave = i << 1;
> + rdwrdata.msgs = 
> + rdwrdata.nmsgs = 1;
> + error = ioctl(fd, I2CRDWR, );
> + } else {
> + cmd.slave = i << 1;
> + cmd.last = 1;
> + error = ioctl(fd, I2CSTART, );
> + if (errno == ENODEV || errno == EOPNOTSUPP) {
> + /* If START not supported try reading. */
> + use_read_xfer = 1;
> + goto start_over;
> + }
> + cmd.slave = i << 1;
> + cmd.last = 1;
> + ioctl(fd, I2CSTOP, );
> + }
> + if (error == 0) {
> + ++num_found;
> + printf("%02x ", i);
> + }

Re: svn commit: r324405 - head/sys/kern

2017-10-10 Thread Jason Eggleston
Sendfile does return EPIPE today. All that has to happen is receiving a RST
after sendfile starts looping.

There is a race condition, which still exists after this suggested patch,
where ECONNRESET could be returned. But mostly it is EPIPE.

On Oct 10, 2017 12:17 AM, "Konstantin Belousov"  wrote:

> On Mon, Oct 09, 2017 at 04:20:52PM -0700, Gleb Smirnoff wrote:
> >   Sean & Jason,
> >
> > On Sat, Oct 07, 2017 at 11:30:57PM +, Sean Bruno wrote:
> > S> Author: sbruno
> > S> Date: Sat Oct  7 23:30:57 2017
> > S> New Revision: 324405
> > S> URL: https://svnweb.freebsd.org/changeset/base/324405
> > S>
> > S> Log:
> > S>   Check so_error early in sendfile() call.  Prior to this patch, if a
> > S>   connection was reset by the remote end, sendfile() would just report
> > S>   ENOTCONN instead of ECONNRESET.
> > S>
> > S>   Submitted by:Jason Eggleston 
> > S>   Reviewed by: glebius
> > S>   Sponsored by:Limelight Networks
> > S>   Differential Revision:   https://reviews.freebsd.org/D12575
> > S>
> > S> Modified:
> > S>   head/sys/kern/kern_sendfile.c
> > S>
> > S> Modified: head/sys/kern/kern_sendfile.c
> > S> 
> ==
> > S> --- head/sys/kern/kern_sendfile.c  Sat Oct  7 23:10:16 2017
> (r324404)
> > S> +++ head/sys/kern/kern_sendfile.c  Sat Oct  7 23:30:57 2017
> (r324405)
> > S> @@ -514,6 +514,11 @@ sendfile_getsock(struct thread *td, int s,
> struct file
> > S>*so = (*sock_fp)->f_data;
> > S>if ((*so)->so_type != SOCK_STREAM)
> > S>return (EINVAL);
> > S> +  if ((*so)->so_error) {
> > S> +  error = (*so)->so_error;
> > S> +  (*so)->so_error = 0;
> > S> +  return (error);
> > S> +  }
> > S>if (((*so)->so_state & SS_ISCONNECTED) == 0)
> > S>return (ENOTCONN);
> > S>return (0);
> >
> > Despite my initial positive review, now I am quite unsure on that.
> >
> > Problem is that sendfile(2) isn't defined by SUS, so there is no
> > distinctive final answer on that. Should we match other OSes?
> > Should we match our historic behaviour? Or should we match
> > write(2)/send(2) to socket, which are closest analogy. I probably
> > believe in the latter: sendfile(2) belongs to write(2)/send(2)
> > family.
> >
> > SUS specifies that write may return ECONNRESET. It also documents
> > EPIPE. However, our manual page documents only EPIPE for both
> > send(2) and write(2). For write we have:
> >
> > SOCKBUF_LOCK(>so_snd);
> > if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
> > SOCKBUF_UNLOCK(>so_snd);
> > error = EPIPE;
> > goto out;
> > }
> > if (so->so_error) {
> > error = so->so_error;
> > so->so_error = 0;
> > SOCKBUF_UNLOCK(>so_snd);
> > goto out;
> > }
> >
> > Indeed, EPIPE will be returned prior to return/clear of so_error,
> > which supposedly is ECONNRESET.
> >
> > In the sendfile(2) implementation we see exactly same code:
> >
> > if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
> > error = EPIPE;
> > SOCKBUF_UNLOCK(>so_snd);
> > goto done;
> > } else if (so->so_error) {
> > error = so->so_error;
> > so->so_error = 0;
> > SOCKBUF_UNLOCK(>so_snd);
> > goto done;
> > }
> >
> > But it isn't reached. Before due to SS_ISCONNECTED check, now
> > due to your change. Now we got two spots where so_error is
> > returned/cleared.
> Do you mean that EPIPE could be returned from sendfile(2) after some
> round of changes ?  It should be not.
>
> EPIPE is a workaround for naive programs that use stdio and cannot detect
> the broken pipe when used as an element in the  shell plumbing.  EPIPE
> results in SIGPIPE terminating such programs (instead of looping endlessly
> when write(2) returns error).
>
> Any application using sendfile(2) must understand the API to properly
> handle
> disconnects, so SIGPIPE workaround would be avoided.  Often such
> applications
> are already sofisticated enough to block SIGPIPE, but if blocking becomes
> a new requirement because EPIPE was not returned in earlier version of
> the system, they might not block it still.
>
> >
> > For the receive family (read(2) and recv(2)), SUS specifies
> > ECONNRESET and our code does that. It also clears so_error.
> >
> > So, after your change at least one standard case is broken: an
> > application that polls/selects for both readability and
> > writeability of a socket. It discovers that socket is available
> > for writing, does sendfile(2), receives ECONNRESET. Then it does
> > read on the socket, and blocks(?) or returns a bogus error(?),
> > not sure. But definitely not ECONNRESET, since it is now cleared.
> >
> > 

svn commit: r324496 - head

2017-10-10 Thread Baptiste Daroussin
Author: bapt
Date: Tue Oct 10 13:06:11 2017
New Revision: 324496
URL: https://svnweb.freebsd.org/changeset/base/324496

Log:
  Do not print error when running make check-old on system
  without catpages directories
  
  Reported by:  dim

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue Oct 10 13:05:26 2017(r324495)
+++ head/Makefile.inc1  Tue Oct 10 13:06:11 2017(r324496)
@@ -2590,7 +2590,7 @@ check-old-files: .PHONY
done; \
done
 # Check for catpages without corresponding manpages.
-   @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
+   @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
sed -ep 
-e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
while read catpage; do \
read manpage; \
___
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"


svn commit: r324495 - in head/sys: arm64/arm64 arm64/include conf modules

2017-10-10 Thread Andrew Turner
Author: andrew
Date: Tue Oct 10 13:05:26 2017
New Revision: 324495
URL: https://svnweb.freebsd.org/changeset/base/324495

Log:
  Support the EFI Runtime Services on arm64. As with amd64 we use the 1:1
  mapping. This uses the new common code shared with amd64.
  
  The RTC should only be accessed via EFI. There is no locking around it as
  the spec only has this as a requirement for the PC-AT CMOS device.
  
  Reviewed by:  kib, imp
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D12595

Added:
  head/sys/arm64/arm64/efirt_machdep.c   (contents, props changed)
Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/include/efi.h
  head/sys/conf/files.arm64
  head/sys/conf/options.arm64
  head/sys/modules/Makefile

Added: head/sys/arm64/arm64/efirt_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/arm64/efirt_machdep.cTue Oct 10 13:05:26 2017
(r324495)
@@ -0,0 +1,252 @@
+/*-
+ * Copyright (c) 2004 Marcel Moolenaar
+ * Copyright (c) 2001 Doug Rabson
+ * Copyright (c) 2016 The FreeBSD Foundation
+ * Copyright (c) 2017 Andrew Turner
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static vm_object_t obj_1t1_pt;
+static vm_page_t efi_l0_page;
+static pd_entry_t *efi_l0;
+
+void
+efi_destroy_1t1_map(void)
+{
+   vm_page_t m;
+
+   if (obj_1t1_pt != NULL) {
+   VM_OBJECT_RLOCK(obj_1t1_pt);
+   TAILQ_FOREACH(m, _1t1_pt->memq, listq)
+   m->wire_count = 0;
+   atomic_subtract_int(_cnt.v_wire_count,
+   obj_1t1_pt->resident_page_count);
+   VM_OBJECT_RUNLOCK(obj_1t1_pt);
+   vm_object_deallocate(obj_1t1_pt);
+   }
+
+   obj_1t1_pt = NULL;
+   efi_l0 = NULL;
+   efi_l0_page = NULL;
+}
+
+static vm_page_t
+efi_1t1_page(vm_pindex_t idx)
+{
+
+   return (vm_page_grab(obj_1t1_pt, idx, VM_ALLOC_NOBUSY |
+   VM_ALLOC_WIRED | VM_ALLOC_ZERO));
+}
+
+static pt_entry_t *
+efi_1t1_l3(vm_offset_t va)
+{
+   pd_entry_t *l0, *l1, *l2;
+   pt_entry_t *l3;
+   vm_pindex_t l0_idx, l1_idx, l2_idx;
+   vm_page_t m;
+   vm_paddr_t mphys;
+
+   l0_idx = pmap_l0_index(va);
+   l0 = _l0[l0_idx];
+   if (*l0 == 0) {
+   m = efi_1t1_page(1 + l0_idx);
+   mphys = VM_PAGE_TO_PHYS(m);
+   *l0 = mphys | L0_TABLE;
+   } else {
+   mphys = *l0 & ~ATTR_MASK;
+   }
+
+   l1 = (pd_entry_t *)PHYS_TO_DMAP(mphys);
+   l1_idx = pmap_l1_index(va);
+   l1 += l1_idx;
+   if (*l1 == 0) {
+   m = efi_1t1_page(1 + L0_ENTRIES + (l0_idx + 1) * (l1_idx + 1));
+   mphys = VM_PAGE_TO_PHYS(m);
+   *l1 = mphys | L1_TABLE;
+   } else {
+   mphys = *l1 & ~ATTR_MASK;
+   }
+
+   l2 = (pd_entry_t *)PHYS_TO_DMAP(mphys);
+   l2_idx = pmap_l2_index(va);
+   l2 += l2_idx;
+   if (*l2 == 0) {
+   m = 

svn commit: r324494 - head/sys/arm64/include

2017-10-10 Thread Andrew Turner
Author: andrew
Date: Tue Oct 10 13:02:58 2017
New Revision: 324494
URL: https://svnweb.freebsd.org/changeset/base/324494

Log:
  Add machine/fpu.h on arm64 for compatibility with amd64.
  
  Sponsored by: DARPA, AFRL

Added:
  head/sys/arm64/include/fpu.h   (contents, props changed)

Added: head/sys/arm64/include/fpu.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/include/fpu.hTue Oct 10 13:02:58 2017
(r324494)
@@ -0,0 +1,6 @@
+/*-
+ * This file is in the public domain.
+ *
+ * $FreeBSD$
+ */
+#include 
___
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"


svn commit: r324493 - in head/sys/arm64: arm64 include

2017-10-10 Thread Andrew Turner
Author: andrew
Date: Tue Oct 10 12:54:36 2017
New Revision: 324493
URL: https://svnweb.freebsd.org/changeset/base/324493

Log:
  Move the pmap_l0_index, etc. macros to pte.h. These will be used by the
  EFI Runtime Services code.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/include/pte.h

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Oct 10 12:36:41 2017(r324492)
+++ head/sys/arm64/arm64/pmap.c Tue Oct 10 12:54:36 2017(r324493)
@@ -306,11 +306,6 @@ pagecopy(void *s, void *d)
memcpy(d, s, PAGE_SIZE);
 }
 
-#definepmap_l0_index(va)   (((va) >> L0_SHIFT) & L0_ADDR_MASK)
-#definepmap_l1_index(va)   (((va) >> L1_SHIFT) & Ln_ADDR_MASK)
-#definepmap_l2_index(va)   (((va) >> L2_SHIFT) & Ln_ADDR_MASK)
-#definepmap_l3_index(va)   (((va) >> L3_SHIFT) & Ln_ADDR_MASK)
-
 static __inline pd_entry_t *
 pmap_l0(pmap_t pmap, vm_offset_t va)
 {

Modified: head/sys/arm64/include/pte.h
==
--- head/sys/arm64/include/pte.hTue Oct 10 12:36:41 2017
(r324492)
+++ head/sys/arm64/include/pte.hTue Oct 10 12:54:36 2017
(r324493)
@@ -118,6 +118,11 @@ typedefuint64_tpt_entry_t; /* page 
table entry */
 #defineLn_ADDR_MASK(Ln_ENTRIES - 1)
 #defineLn_TABLE_MASK   ((1 << 12) - 1)
 
+#definepmap_l0_index(va)   (((va) >> L0_SHIFT) & L0_ADDR_MASK)
+#definepmap_l1_index(va)   (((va) >> L1_SHIFT) & Ln_ADDR_MASK)
+#definepmap_l2_index(va)   (((va) >> L2_SHIFT) & Ln_ADDR_MASK)
+#definepmap_l3_index(va)   (((va) >> L3_SHIFT) & Ln_ADDR_MASK)
+
 #endif /* !_MACHINE_PTE_H_ */
 
 /* End of pte.h */
___
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"


svn commit: r324492 - head/sys/ofed/include/rdma

2017-10-10 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct 10 12:36:41 2017
New Revision: 324492
URL: https://svnweb.freebsd.org/changeset/base/324492

Log:
  Make sure the IPv6 scope ID gets zeroed inside the GID. Else searching for a
  valid GID entry based on IPv6 addresses can fail.
  
  Sponsored by: Mellanox Technologies
  MFC after:1 week

Modified:
  head/sys/ofed/include/rdma/ib_addr.h

Modified: head/sys/ofed/include/rdma/ib_addr.h
==
--- head/sys/ofed/include/rdma/ib_addr.hTue Oct 10 12:24:52 2017
(r324491)
+++ head/sys/ofed/include/rdma/ib_addr.hTue Oct 10 12:36:41 2017
(r324492)
@@ -157,6 +157,12 @@ static inline int rdma_ip2gid(struct sockaddr *addr, u
case AF_INET6:
memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr,
   16);
+   /* make sure scope ID gets zeroed inside GID */
+   if (IN6_IS_SCOPE_LINKLOCAL((struct in6_addr *)gid->raw) ||
+   IN6_IS_ADDR_MC_INTFACELOCAL((struct in6_addr *)gid->raw)) {
+   gid->raw[2] = 0;
+   gid->raw[3] = 0;
+   }
break;
default:
return -EINVAL;
___
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"


svn commit: r324491 - head/sys/dev/mlx5/mlx5_ib

2017-10-10 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct 10 12:24:52 2017
New Revision: 324491
URL: https://svnweb.freebsd.org/changeset/base/324491

Log:
  Use common rdma_ip2gid() function instead of custom mlx5_ip2gid() one.
  
  Sponsored by: Mellanox Technologies
  MFC after:1 week

Modified:
  head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c

Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
==
--- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.cTue Oct 10 12:10:19 2017
(r324490)
+++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.cTue Oct 10 12:24:52 2017
(r324491)
@@ -562,26 +562,6 @@ mlx5_make_default_gid(struct net_device *dev, union ib
mlx5_addrconf_ifid_eui48(>raw[8], dev);
 }
 
-static inline int
-mlx5_ip2gid(const struct sockaddr *addr, union ib_gid *gid)
-{
-   switch (addr->sa_family) {
-   case AF_INET:
-   ipv6_addr_set_v4mapped(((const struct sockaddr_in 
*)addr)->sin_addr.s_addr,
-   (struct in6_addr *)gid->raw);
-   break;
-   case AF_INET6:
-   memcpy(gid->raw, &((const struct sockaddr_in6 
*)addr)->sin6_addr, 16);
-   /* clear SCOPE ID */
-   gid->raw[2] = 0;
-   gid->raw[3] = 0;
-   break;
-   default:
-   return -EINVAL;
-   }
-   return 0;
-}
-
 static void
 mlx5_ib_roce_port_update(void *arg)
 {
@@ -639,7 +619,7 @@ mlx5_ib_roce_port_update(void *arg)
gid_index >= MLX5_IB_GID_MAX)
continue;
memset(_temp, 0, sizeof(gid_temp));
-   mlx5_ip2gid(ifa->ifa_addr, _temp);
+   rdma_ip2gid(ifa->ifa_addr, _temp);
/* check for existing entry */
for (j = 0; j != gid_index; j++) {
if (bcmp(_temp, 
>gid_table[j], sizeof(gid_temp)) == 0)
___
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"


svn commit: r324490 - head/sys/contrib/rdma/krping

2017-10-10 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct 10 12:10:19 2017
New Revision: 324490
URL: https://svnweb.freebsd.org/changeset/base/324490

Log:
  Add support for parsing and using IPv6 addresses in krping.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/contrib/rdma/krping/krping.c

Modified: head/sys/contrib/rdma/krping/krping.c
==
--- head/sys/contrib/rdma/krping/krping.c   Tue Oct 10 08:32:03 2017
(r324489)
+++ head/sys/contrib/rdma/krping/krping.c   Tue Oct 10 12:10:19 2017
(r324490)
@@ -86,6 +86,7 @@ static const struct krping_option krping_opts[] = {
{"count", OPT_INT, 'C'},
{"size", OPT_INT, 'S'},
{"addr", OPT_STRING, 'a'},
+   {"addr6", OPT_STRING, 'A'},
{"port", OPT_INT, 'p'},
{"verbose", OPT_NOPARAM, 'v'},
{"validate", OPT_NOPARAM, 'V'},
@@ -220,7 +221,11 @@ struct krping_cb {
struct krping_stats stats;
 
uint16_t port;  /* dst port in NBO */
-   struct in_addr addr;/* dst addr in NBO */
+   union {
+   struct in_addr v4;
+   struct in6_addr v6;
+   } addr; /* dst addr in NBO */
+   int addr_type;  /* AF_INET or AF_INET6 */
char *addr_str; /* dst addr string */
int verbose;/* verbose logging */
int count;  /* ping count */
@@ -1600,15 +1605,31 @@ static int fastreg_supported(struct krping_cb *cb, int
 
 static int krping_bind_server(struct krping_cb *cb)
 {
-   struct sockaddr_in sin;
+   union {
+   struct sockaddr_in v4;
+   struct sockaddr_in6 v6;
+   } sin;
int ret;
 
memset(, 0, sizeof(sin));
-   sin.sin_len = sizeof sin;
-   sin.sin_family = AF_INET;
-   sin.sin_addr.s_addr = cb->addr.s_addr;
-   sin.sin_port = cb->port;
 
+   switch (cb->addr_type) {
+   case AF_INET:
+   sin.v4.sin_len = sizeof sin.v4;
+   sin.v4.sin_family = AF_INET;
+   sin.v4.sin_addr = cb->addr.v4;
+   sin.v4.sin_port = cb->port;
+   break;
+   case AF_INET6:
+   sin.v6.sin6_len = sizeof sin.v6;
+   sin.v6.sin6_family = AF_INET6;
+   sin.v6.sin6_addr = cb->addr.v6;
+   sin.v6.sin6_port = cb->port;
+   break;
+   default:
+   return (-EINVAL);
+   }
+
ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *) );
if (ret) {
PRINTF(cb, "rdma_bind_addr error %d\n", ret);
@@ -3059,15 +3080,31 @@ static int krping_connect_client(struct krping_cb *cb)
 
 static int krping_bind_client(struct krping_cb *cb)
 {
-   struct sockaddr_in sin;
+   union {
+   struct sockaddr_in v4;
+   struct sockaddr_in6 v6;
+   } sin;
int ret;
 
memset(, 0, sizeof(sin));
-   sin.sin_len = sizeof sin;
-   sin.sin_family = AF_INET;
-   sin.sin_addr.s_addr = cb->addr.s_addr;
-   sin.sin_port = cb->port;
 
+   switch (cb->addr_type) {
+   case AF_INET:
+   sin.v4.sin_len = sizeof sin.v4;
+   sin.v4.sin_family = AF_INET;
+   sin.v4.sin_addr = cb->addr.v4;
+   sin.v4.sin_port = cb->port;
+   break;
+   case AF_INET6:
+   sin.v6.sin6_len = sizeof sin.v6;
+   sin.v6.sin6_family = AF_INET6;
+   sin.v6.sin6_addr = cb->addr.v6;
+   sin.v6.sin6_port = cb->port;
+   break;
+   default:
+   return (-EINVAL);
+   }
+
ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) ,
2000);
if (ret) {
@@ -3140,12 +3177,29 @@ err1:
krping_free_qp(cb);
 }
 
+static uint16_t
+krping_get_ipv6_scope_id(char *name)
+{
+   struct ifnet *ifp;
+   uint16_t retval;
+
+   if (name == NULL)
+   return (0);
+   ifp = ifunit_ref(name);
+   if (ifp == NULL)
+   return (0);
+   retval = ifp->if_index;
+   if_rele(ifp);
+   return (retval);
+}
+
 int krping_doit(char *cmd, void *cookie)
 {
struct krping_cb *cb;
int op;
int ret = 0;
char *optarg;
+   char *scope;
unsigned long optint;
 
cb = kzalloc(sizeof(*cb), GFP_KERNEL);
@@ -3162,6 +3216,7 @@ int krping_doit(char *cmd, void *cookie)
cb->size = 64;
cb->txdepth = RPING_SQ_DEPTH;
cb->mem = DMA;
+   cb->addr_type = AF_INET;
init_waitqueue_head(>sem);
 
while ((op = krping_getopt("krping", , krping_opts, NULL, ,
@@ -3169,11 +3224,33 @@ int krping_doit(char *cmd, void *cookie)
switch (op) {
case 'a':
cb->addr_str = optarg;
-  

svn commit: r324489 - head/sys/dev/hyperv/netvsc

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Tue Oct 10 08:32:03 2017
New Revision: 324489
URL: https://svnweb.freebsd.org/changeset/base/324489

Log:
  hyperv/hn: Workaround erroneous hash type observed on WS2016.
  
  Background:
  - UDP 4-tuple hash type is unconditionally enabled in Hyper-V on WS2016,
which is _not_ affected by NDIS_OBJTYPE_RSS_PARAMS.
  - Non-fragment UDP/IPv4 datagrams' hash type is delivered to VM as
TCP_IPV4.
  
  Currently this erroneous behavior only applies to WS2016/Windows10.
  
  Force l3/l4 protocol check, if the RXed packet's hash type is TCP_IPV4,
  and the Hyper-V is running on WS2016/Windows10.  If the RXed packet is
  UDP datagram, adjust mbuf hash type to UDP_IPV4.
  
  MFC after:3 days
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/netvsc/hn_nvs.c
  head/sys/dev/hyperv/netvsc/if_hn.c
  head/sys/dev/hyperv/netvsc/if_hnvar.h

Modified: head/sys/dev/hyperv/netvsc/hn_nvs.c
==
--- head/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 08:23:19 2017
(r324488)
+++ head/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 08:32:03 2017
(r324489)
@@ -601,6 +601,11 @@ hn_nvs_attach(struct hn_softc *sc, int mtu)
 {
int error;
 
+   if (hyperv_ver_major >= 10) {
+   /* UDP 4-tuple hash is enforced. */
+   sc->hn_caps |= HN_CAP_UDPHASH;
+   }
+
/*
 * Initialize NVS.
 */

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==
--- head/sys/dev/hyperv/netvsc/if_hn.c  Tue Oct 10 08:23:19 2017
(r324488)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Tue Oct 10 08:32:03 2017
(r324489)
@@ -385,6 +385,7 @@ static void hn_link_status(struct hn_softc 
*);
 static int hn_create_rx_data(struct hn_softc *, int);
 static voidhn_destroy_rx_data(struct hn_softc *);
 static int hn_check_iplen(const struct mbuf *, int);
+static voidhn_rxpkt_proto(const struct mbuf *, int *, int 
*);
 static int hn_set_rxfilter(struct hn_softc *, uint32_t);
 static int hn_rxfilter_config(struct hn_softc *);
 static int hn_rss_reconfig(struct hn_softc *);
@@ -399,6 +400,7 @@ static int  hn_tx_ring_create(struct 
hn_softc *, int)
 static voidhn_tx_ring_destroy(struct hn_tx_ring *);
 static int hn_create_tx_data(struct hn_softc *, int);
 static voidhn_fixup_tx_data(struct hn_softc *);
+static voidhn_fixup_rx_data(struct hn_softc *);
 static voidhn_destroy_tx_data(struct hn_softc *);
 static voidhn_txdesc_dmamap_destroy(struct hn_txdesc *);
 static voidhn_txdesc_gc(struct hn_tx_ring *,
@@ -2238,9 +2240,10 @@ hn_attach(device_t dev)
 #endif
 
/*
-* Fixup TX stuffs after synthetic parts are attached.
+* Fixup TX/RX stuffs after synthetic parts are attached.
 */
hn_fixup_tx_data(sc);
+   hn_fixup_rx_data(sc);
 
ctx = device_get_sysctl_ctx(dev);
child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
@@ -3378,6 +3381,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int
struct mbuf *m_new;
int size, do_lro = 0, do_csum = 1, is_vf = 0;
int hash_type = M_HASHTYPE_NONE;
+   int l3proto = ETHERTYPE_MAX, l4proto = IPPROTO_DONE;
 
ifp = hn_ifp;
if (rxr->hn_rxvf_ifp != NULL) {
@@ -3477,31 +3481,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int
(NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK))
do_lro = 1;
} else {
-   const struct ether_header *eh;
-   uint16_t etype;
-   int hoff;
-
-   hoff = sizeof(*eh);
-   /* Checked at the beginning of this function. */
-   KASSERT(m_new->m_len >= hoff, ("not ethernet frame"));
-
-   eh = mtod(m_new, struct ether_header *);
-   etype = ntohs(eh->ether_type);
-   if (etype == ETHERTYPE_VLAN) {
-   const struct ether_vlan_header *evl;
-
-   hoff = sizeof(*evl);
-   if (m_new->m_len < hoff)
-   goto skip;
-   evl = mtod(m_new, struct ether_vlan_header *);
-   etype = ntohs(evl->evl_proto);
-   }
-
-   if (etype == ETHERTYPE_IP) {
-   int pr;
-
-   pr = hn_check_iplen(m_new, hoff);
-   if (pr == IPPROTO_TCP) {
+   hn_rxpkt_proto(m_new, , );
+   if (l3proto == ETHERTYPE_IP) {
+   if (l4proto == IPPROTO_TCP) {
if 

svn commit: r324488 - in head/sys/dev/hyperv: include vmbus

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Tue Oct 10 08:23:19 2017
New Revision: 324488
URL: https://svnweb.freebsd.org/changeset/base/324488

Log:
  hyperv/vmbus: Expose Hyper-V major version.
  
  MFC after:3 days
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/vmbus/hyperv.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==
--- head/sys/dev/hyperv/include/hyperv.hTue Oct 10 08:16:55 2017
(r324487)
+++ head/sys/dev/hyperv/include/hyperv.hTue Oct 10 08:23:19 2017
(r324488)
@@ -90,6 +90,7 @@ int   hyperv_guid2str(const struct 
hyperv_guid *, char
  */
 extern hyperv_tc64_t   hyperv_tc64;
 extern u_int   hyperv_features;/* CPUID_HV_MSR_ */
+extern u_int   hyperv_ver_major;
 
 #endif /* _KERNEL */
 

Modified: head/sys/dev/hyperv/vmbus/hyperv.c
==
--- head/sys/dev/hyperv/vmbus/hyperv.c  Tue Oct 10 08:16:55 2017
(r324487)
+++ head/sys/dev/hyperv/vmbus/hyperv.c  Tue Oct 10 08:23:19 2017
(r324488)
@@ -77,6 +77,8 @@ static u_int  hyperv_get_timecount(struct 
timecounter
 static boolhyperv_identify(void);
 static voidhypercall_memfree(void);
 
+u_int  hyperv_ver_major;
+
 u_int  hyperv_features;
 u_int  hyperv_recommends;
 
@@ -169,8 +171,9 @@ hyperv_identify(void)
hyperv_features3 = regs[3];
 
do_cpuid(CPUID_LEAF_HV_IDENTITY, regs);
+   hyperv_ver_major = regs[1] >> 16;
printf("Hyper-V Version: %d.%d.%d [SP%d]\n",
-   regs[1] >> 16, regs[1] & 0x, regs[0], regs[2]);
+   hyperv_ver_major, regs[1] & 0x, regs[0], regs[2]);
 
printf("  Features=0x%b\n", hyperv_features,
"\020"
___
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"


svn commit: r324487 - head/sys/dev/hyperv/vmbus

2017-10-10 Thread Sepherosa Ziehau
Author: sephe
Date: Tue Oct 10 08:16:55 2017
New Revision: 324487
URL: https://svnweb.freebsd.org/changeset/base/324487

Log:
  hyperv/vmbus: Add tunable to pin/unpin event tasks.
  
  Event tasks are pinned to their respective CPU by default, in the same
  fashion as they were.
  
  Unpin the event tasks by setting hw.vmbus.pin_evttask to 0, if certain
  CPUs serve special purpose.
  
  MFC after:3 days
  Sponsored by: Microsoft

Modified:
  head/sys/dev/hyperv/vmbus/vmbus.c

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==
--- head/sys/dev/hyperv/vmbus/vmbus.c   Tue Oct 10 08:07:05 2017
(r324486)
+++ head/sys/dev/hyperv/vmbus/vmbus.c   Tue Oct 10 08:16:55 2017
(r324487)
@@ -128,6 +128,13 @@ static void
vmbus_event_proc_dummy(struct vmbus_soft
 
 static struct vmbus_softc  *vmbus_sc;
 
+SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+"Hyper-V vmbus");
+
+static int vmbus_pin_evttask = 1;
+SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN,
+_pin_evttask, 0, "Pin event tasks to their respective CPU");
+
 extern inthand_t IDTVEC(vmbus_isr);
 
 static const uint32_t  vmbus_version[] = {
@@ -905,10 +912,16 @@ vmbus_intr_setup(struct vmbus_softc *sc)
VMBUS_PCPU_GET(sc, event_tq, cpu) = taskqueue_create_fast(
"hyperv event", M_WAITOK, taskqueue_thread_enqueue,
VMBUS_PCPU_PTR(sc, event_tq, cpu));
-   CPU_SETOF(cpu, _mask);
-   taskqueue_start_threads_cpuset(
-   VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET, _mask,
-   "hvevent%d", cpu);
+   if (vmbus_pin_evttask) {
+   CPU_SETOF(cpu, _mask);
+   taskqueue_start_threads_cpuset(
+   VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET,
+   _mask, "hvevent%d", cpu);
+   } else {
+   taskqueue_start_threads(
+   VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET,
+   "hvevent%d", cpu);
+   }
 
/*
 * Setup tasks and taskqueues to handle messages.
___
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"


Re: svn commit: r324405 - head/sys/kern

2017-10-10 Thread Konstantin Belousov
On Mon, Oct 09, 2017 at 04:20:52PM -0700, Gleb Smirnoff wrote:
>   Sean & Jason,
> 
> On Sat, Oct 07, 2017 at 11:30:57PM +, Sean Bruno wrote:
> S> Author: sbruno
> S> Date: Sat Oct  7 23:30:57 2017
> S> New Revision: 324405
> S> URL: https://svnweb.freebsd.org/changeset/base/324405
> S> 
> S> Log:
> S>   Check so_error early in sendfile() call.  Prior to this patch, if a
> S>   connection was reset by the remote end, sendfile() would just report
> S>   ENOTCONN instead of ECONNRESET.
> S>   
> S>   Submitted by:Jason Eggleston 
> S>   Reviewed by: glebius
> S>   Sponsored by:Limelight Networks
> S>   Differential Revision:   https://reviews.freebsd.org/D12575
> S> 
> S> Modified:
> S>   head/sys/kern/kern_sendfile.c
> S> 
> S> Modified: head/sys/kern/kern_sendfile.c
> S> 
> ==
> S> --- head/sys/kern/kern_sendfile.c  Sat Oct  7 23:10:16 2017
> (r324404)
> S> +++ head/sys/kern/kern_sendfile.c  Sat Oct  7 23:30:57 2017
> (r324405)
> S> @@ -514,6 +514,11 @@ sendfile_getsock(struct thread *td, int s, struct file
> S>*so = (*sock_fp)->f_data;
> S>if ((*so)->so_type != SOCK_STREAM)
> S>return (EINVAL);
> S> +  if ((*so)->so_error) {
> S> +  error = (*so)->so_error;
> S> +  (*so)->so_error = 0;
> S> +  return (error);
> S> +  }
> S>if (((*so)->so_state & SS_ISCONNECTED) == 0)
> S>return (ENOTCONN);
> S>return (0);
> 
> Despite my initial positive review, now I am quite unsure on that.
> 
> Problem is that sendfile(2) isn't defined by SUS, so there is no
> distinctive final answer on that. Should we match other OSes?
> Should we match our historic behaviour? Or should we match
> write(2)/send(2) to socket, which are closest analogy. I probably
> believe in the latter: sendfile(2) belongs to write(2)/send(2)
> family.
> 
> SUS specifies that write may return ECONNRESET. It also documents
> EPIPE. However, our manual page documents only EPIPE for both
> send(2) and write(2). For write we have:
> 
> SOCKBUF_LOCK(>so_snd);
> if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
> SOCKBUF_UNLOCK(>so_snd);
> error = EPIPE;
> goto out;
> }
> if (so->so_error) {
> error = so->so_error;
> so->so_error = 0;
> SOCKBUF_UNLOCK(>so_snd);
> goto out;
> }
> 
> Indeed, EPIPE will be returned prior to return/clear of so_error,
> which supposedly is ECONNRESET.
> 
> In the sendfile(2) implementation we see exactly same code:
> 
> if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
> error = EPIPE;
> SOCKBUF_UNLOCK(>so_snd);
> goto done;
> } else if (so->so_error) {
> error = so->so_error;
> so->so_error = 0;
> SOCKBUF_UNLOCK(>so_snd);
> goto done;
> }
> 
> But it isn't reached. Before due to SS_ISCONNECTED check, now
> due to your change. Now we got two spots where so_error is
> returned/cleared.
Do you mean that EPIPE could be returned from sendfile(2) after some
round of changes ?  It should be not.

EPIPE is a workaround for naive programs that use stdio and cannot detect
the broken pipe when used as an element in the  shell plumbing.  EPIPE
results in SIGPIPE terminating such programs (instead of looping endlessly
when write(2) returns error).

Any application using sendfile(2) must understand the API to properly handle
disconnects, so SIGPIPE workaround would be avoided.  Often such applications
are already sofisticated enough to block SIGPIPE, but if blocking becomes
a new requirement because EPIPE was not returned in earlier version of
the system, they might not block it still.

> 
> For the receive family (read(2) and recv(2)), SUS specifies
> ECONNRESET and our code does that. It also clears so_error.
> 
> So, after your change at least one standard case is broken: an
> application that polls/selects for both readability and
> writeability of a socket. It discovers that socket is available
> for writing, does sendfile(2), receives ECONNRESET. Then it does
> read on the socket, and blocks(?) or returns a bogus error(?),
> not sure. But definitely not ECONNRESET, since it is now cleared.
> 
> Now, where does this ENOTCONN come from? These two lines:
> 
>   if (((*so)->so_state & SS_ISCONNECTED) == 0)
>   return (ENOTCONN);
> 
> can be traced back all the way to original 1998 commit of sendfile.
> 
> Here comes difference between sendfile(2) and send(2). In send(2),
> this check is done _after_ so_error check, so your change is correct
> in placing of so_error check wrt so_state check, but is incorrect
> in placing wrt socket buffer state check.
> 
> After all this