Re: [Patch fuse] fusefs_link return code

2014-05-19 Thread Sylvestre Gallon
On Wed, May 7, 2014 at 10:36 AM, Sylvestre Gallon ccna@gmail.com wrote:
 On Mon, May 05, 2014 at 08:40:10PM +0800, Helg wrote:
 This patch fixes a bug where fusefs_link does not return an error on
 subsequent invocations if a fuse filesystem does not implement hard
 links.

 As an aside, returning ENOSYS in this case is contrary to the link(2)
 man page (and different again to the Open Group) but consistent with
 the fuse implementation on Linux.

 --
 Helg xx...@msn.com


 Index: fuse_vnops.c
 ===
 RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
 retrieving revision 1.16
 diff -u -p -r1.16 fuse_vnops.c
 --- fuse_vnops.c18 Mar 2014 08:51:53 -  1.16
 +++ fuse_vnops.c4 May 2014 06:32:50 -
 @@ -540,8 +540,10 @@ fusefs_link(void *v)
 dip = VTOI(dvp);
 fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;

 -   if (!fmp-sess_init || (fmp-undef_op  UNDEF_LINK))
 +   if (!fmp-sess_init || (fmp-undef_op  UNDEF_LINK)) {
 +   error = ENOSYS;
 goto out1;
 +   }

 fbuf = fb_setup(cnp-cn_namelen + 1, dip-ufs_ino.i_number,
 FBT_LINK, p);


 Hi,

 Thanks for your diff. Here is an updated version that adds some
 consistency on fuse error handling. We need to return ENXIO when
 the fuse communication channel is broken and ENOSYS when the libfuse
 callback does not exist.

 I've also modified some vnops to be sure that the checks for active
 fuse communication channel and for libfuse callbacks presence are
 done first...

 Any OK ?

 Cheers,

Anyone ?

-- 
Sylvestre Gallon



Re: [Patch fuse] fusefs_link return code

2014-05-07 Thread Sylvestre Gallon
On Mon, May 05, 2014 at 08:40:10PM +0800, Helg wrote:
 This patch fixes a bug where fusefs_link does not return an error on
 subsequent invocations if a fuse filesystem does not implement hard
 links.
 
 As an aside, returning ENOSYS in this case is contrary to the link(2)
 man page (and different again to the Open Group) but consistent with
 the fuse implementation on Linux.
 
 -- 
 Helg xx...@msn.com
 
 
 Index: fuse_vnops.c
 ===
 RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
 retrieving revision 1.16
 diff -u -p -r1.16 fuse_vnops.c
 --- fuse_vnops.c18 Mar 2014 08:51:53 -  1.16
 +++ fuse_vnops.c4 May 2014 06:32:50 -
 @@ -540,8 +540,10 @@ fusefs_link(void *v)
 dip = VTOI(dvp);
 fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
  
 -   if (!fmp-sess_init || (fmp-undef_op  UNDEF_LINK))
 +   if (!fmp-sess_init || (fmp-undef_op  UNDEF_LINK)) {
 +   error = ENOSYS;
 goto out1;
 +   }
  
 fbuf = fb_setup(cnp-cn_namelen + 1, dip-ufs_ino.i_number,
 FBT_LINK, p);
 

Hi,

Thanks for your diff. Here is an updated version that adds some
consistency on fuse error handling. We need to return ENXIO when
the fuse communication channel is broken and ENOSYS when the libfuse
callback does not exist.

I've also modified some vnops to be sure that the checks for active
fuse communication channel and for libfuse callbacks presence are 
done first...

Any OK ?

Cheers,

Index: fuse_vnops.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 fuse_vnops.c
--- fuse_vnops.c18 Mar 2014 08:51:53 -  1.16
+++ fuse_vnops.c7 May 2014 08:17:57 -
@@ -202,7 +202,7 @@ fusefs_open(void *v)
fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
 
if (!fmp-sess_init)
-   return (0);
+   return (ENXIO);
 
isdir = 0;
if (ip-vtype == VDIR)
@@ -293,7 +293,10 @@ fusefs_access(void *v)
ip = VTOI(ap-a_vp);
fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
 
-   if (!fmp-sess_init || (fmp-undef_op  UNDEF_ACCESS))
+   if (!fmp-sess_init)
+   return (ENXIO);
+
+   if (fmp-undef_op  UNDEF_ACCESS)
goto system_check;
 
if (ap-a_vp-v_type == VLNK)
@@ -358,7 +361,7 @@ fusefs_getattr(void *v)
fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
 
if (!fmp-sess_init)
-   goto fake;
+   return (ENXIO);
 
fbuf = fb_setup(0, ip-ufs_ino.i_number, FBT_GETATTR, p);
 
@@ -372,10 +375,6 @@ fusefs_getattr(void *v)
memcpy(vap, fbuf-fb_vattr, sizeof(*vap));
fb_delete(fbuf);
return (error);
-fake:
-   bzero(vap, sizeof(*vap));
-   vap-va_type = vp-v_type;
-   return (0);
 }
 
 int
@@ -401,9 +400,12 @@ fusefs_setattr(void *v)
((int)vap-va_bytes != VNOVAL) || (vap-va_gen != VNOVAL))
return (EINVAL);
 
-   if (!fmp-sess_init || (fmp-undef_op  UNDEF_SETATTR))
+   if (!fmp-sess_init)
return (ENXIO);
 
+   if (fmp-undef_op  UNDEF_SETATTR)
+   return (ENOSYS);
+
fbuf = fb_setup(sizeof(*io), ip-ufs_ino.i_number, FBT_SETATTR, p);
io = fbtod(fbuf, struct fb_io *);
io-fi_flags = 0;
@@ -521,6 +523,20 @@ fusefs_link(void *v)
struct fusebuf *fbuf;
int error = 0;
 
+   ip = VTOI(vp);
+   dip = VTOI(dvp);
+   fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
+
+   if (!fmp-sess_init) {
+   VOP_ABORTOP(dvp, cnp);
+   error = ENXIO;
+   goto out2;
+   }
+   if (fmp-undef_op  UNDEF_LINK) {
+   VOP_ABORTOP(dvp, cnp);
+   error = ENOSYS;
+   goto out2;
+   }
if (vp-v_type == VDIR) {
VOP_ABORTOP(dvp, cnp);
error = EISDIR;
@@ -536,13 +552,6 @@ fusefs_link(void *v)
goto out2;
}
 
-   ip = VTOI(vp);
-   dip = VTOI(dvp);
-   fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
-
-   if (!fmp-sess_init || (fmp-undef_op  UNDEF_LINK))
-   goto out1;
-
fbuf = fb_setup(cnp-cn_namelen + 1, dip-ufs_ino.i_number,
FBT_LINK, p);
 
@@ -591,7 +600,12 @@ fusefs_symlink(void *v)
dp = VTOI(dvp);
fmp = (struct fusefs_mnt *)dp-ufs_ino.i_ump;
 
-   if (!fmp-sess_init  || (fmp-undef_op  UNDEF_SYMLINK)) {
+   if (!fmp-sess_init) {
+   error = ENXIO;
+   goto bad;
+   }
+
+   if (fmp-undef_op  UNDEF_SYMLINK) {
error = ENOSYS;
goto bad;
}
@@ -652,7 +666,7 @@ fusefs_readdir(void *v)
fmp = (struct fusefs_mnt *)ip-ufs_ino.i_ump;
 
if (!fmp-sess_init)
-   return (0);
+   return (ENXIO);
 
if 

Re: [Patch fuselib] Support 255 character file names

2014-04-28 Thread Sylvestre Gallon
On Sun, Apr 27, 2014 at 2:37 AM, Helg xx...@msn.com wrote:
 I've been doing some testing of fuse and discovered a small bug where it only 
 allows file names up to 254 characters due to not taking the NULL terminator 
 into consideration when allocating structures.

This has been commited (with few changes), thanks!



Re: Hangs with Fuse

2013-12-16 Thread Sylvestre Gallon
On Mon, Dec 16, 2013 at 5:35 PM, Gregor Best g...@ring0.de wrote:
 Hi Sylvestre,


Hi Gregor.


 while playing around with sshfs, I noticed a peculiar behaviour. If I
 mount it somewhere and run something like

 find /mnt/fuse -type f -name '*.core'

 on it, everything seems to work fine until the network connection is
 interrupted. The system then hangs, with only the keyboard LEDs like the
 caps lock indicator working (i.e. pressing caps lock turns the LED on
 and off, but nothing else seems to work). The simplest way to reproduce
 this is via something like the following:

 sshfs user@somehost:/foo /mnt/fuse
 while true; do find /mnt/fuse -type f; done 
 while sleep 1; date; done

Did you use the last snapshots ? If yes you need to recompile your
libfuse and your kernel to get the last changes.

We have solved some issues like that with pelikan@.

I've tested your command it seems to works well on current for amd64.
When the network is down all vfs access get timeouts but I've no
freeze here.

Cheers,
-- 
Sylvestre Gallon



Re: sdmmc update

2013-12-02 Thread Sylvestre Gallon
On Wed, Nov 20, 2013 at 10:25:52AM +0100, Stefan Sperling wrote:
 On Thu, Nov 07, 2013 at 08:10:16PM +0100, Stefan Sperling wrote:
  On Thu, Nov 07, 2013 at 08:06:11PM +0100, Sylvestre Gallon wrote:
   +int
   +rtsx_bus_width(sdmmc_chipset_handle_t sch, int width)
   +{
   + struct rtsx_softc *sc = sch;
   +
   + return (rtsx_set_bus_width(sc, width));
  
  rtsx_set_bus_width() currently never returns an error so you'll
  need to tweak it as well.
  
  I will test your diff on rtsx and sdhc.
 
 This diff works with sdhc and provides an increase in read performance.
 
 Unfortunately, the diff breaks rtsx. The disk manages to attach after
 a CRC error, but it cannot be read. We'll need to figure this out.
 

Hi,

Does this diff works better ? I have just renable these lines in 
rtsx_bus_power() :

-   error = rtsx_set_bus_width(sc, 1);
-   if (error)
-   goto ret;

If it still not work with this diff can you add a printf in the
bus_clock code to know which frequency is required by the stack ?

Thanks,

Index: arch/arm/xscale/pxa2x0_mmc.c
===
RCS file: /cvs/src/sys/arch/arm/xscale/pxa2x0_mmc.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 pxa2x0_mmc.c
--- arch/arm/xscale/pxa2x0_mmc.c22 Aug 2012 13:37:04 -  1.11
+++ arch/arm/xscale/pxa2x0_mmc.c2 Dec 2013 15:34:18 -
@@ -56,6 +56,7 @@ u_int32_t pxammc_host_ocr(sdmmc_chipset_
 intpxammc_host_maxblklen(sdmmc_chipset_handle_t);
 intpxammc_card_detect(sdmmc_chipset_handle_t);
 intpxammc_bus_power(sdmmc_chipset_handle_t, u_int32_t);
+intpxammc_bus_width(sdmmc_chipset_handle_t, int);
 intpxammc_bus_clock(sdmmc_chipset_handle_t, int);
 void   pxammc_exec_command(sdmmc_chipset_handle_t, struct sdmmc_command *);
 void   pxammc_clock_stop(struct pxammc_softc *);
@@ -90,6 +91,7 @@ struct sdmmc_chip_functions pxammc_funct
/* bus power and clock frequency */
pxammc_bus_power,
pxammc_bus_clock,
+   pxammc_bus_width,
/* command execution */
pxammc_exec_command
 };
@@ -179,6 +181,8 @@ pxammc_attach(struct pxammc_softc *sc, v
 */
bzero(saa, sizeof saa);
saa.saa_busname = sdmmc;
+   saa.saa_clkmax = SDMMC_SDCLK_25MHZ;
+
saa.sct = pxammc_functions;
saa.sch = sc;
saa.flags = SMF_STOP_AFTER_MULTIPLE;
@@ -274,6 +278,12 @@ pxammc_bus_power(sdmmc_chipset_handle_t 
DPRINTF(0,(%s: driver lacks set_power() function\n,
sc-sc_dev.dv_xname));
return ENXIO;
+}
+
+int
+pxammc_bus_width(sdmmc_chipset_handle_t sch, int width)
+{
+   return (0);
 }
 
 int
Index: arch/armv7/imx/imxesdhc.c
===
RCS file: /cvs/src/sys/arch/armv7/imx/imxesdhc.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 imxesdhc.c
--- arch/armv7/imx/imxesdhc.c   6 Nov 2013 19:03:07 -   1.4
+++ arch/armv7/imx/imxesdhc.c   2 Dec 2013 15:34:18 -
@@ -195,6 +195,7 @@ int imxesdhc_host_maxblklen(sdmmc_chipse
 intimxesdhc_card_detect(sdmmc_chipset_handle_t);
 intimxesdhc_bus_power(sdmmc_chipset_handle_t, uint32_t);
 intimxesdhc_bus_clock(sdmmc_chipset_handle_t, int);
+intimxesdhc_bus_width(sdmmc_chipset_handle_t, int);
 void   imxesdhc_card_intr_mask(sdmmc_chipset_handle_t, int);
 void   imxesdhc_card_intr_ack(sdmmc_chipset_handle_t);
 void   imxesdhc_exec_command(sdmmc_chipset_handle_t, struct sdmmc_command *);
@@ -225,6 +226,7 @@ struct sdmmc_chip_functions imxesdhc_fun
/* bus power and clock frequency */
imxesdhc_bus_power,
imxesdhc_bus_clock,
+   imxesdhc_bus_width,
/* command execution */
imxesdhc_exec_command,
/* card interrupt */
@@ -319,6 +321,7 @@ imxesdhc_attach(struct device *parent, s
 
bzero(saa, sizeof(saa));
saa.saa_busname = sdmmc;
+   saa.saa_clkmax = SDMMC_SDCLK_25MHZ;
saa.sct = imxesdhc_functions;
saa.sch = sc;
 
@@ -327,7 +330,7 @@ imxesdhc_attach(struct device *parent, s
error = 0;
goto err;
}
-   
+
return;
 
 err:
@@ -483,6 +486,12 @@ imxesdhc_card_detect(sdmmc_chipset_handl
  */
 int
 imxesdhc_bus_power(sdmmc_chipset_handle_t sch, uint32_t ocr)
+{
+   return 0;
+}
+
+int
+imxesdhc_bus_width(sdmmc_chipset_handle_t sch, int freq)
 {
return 0;
 }
Index: arch/armv7/omap/ommmc.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/ommmc.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 ommmc.c
--- arch/armv7/omap/ommmc.c 12 Nov 2013 17:51:52 -  1.11
+++ arch/armv7/omap/ommmc.c 2 Dec 2013 15:34:18 -
@@ -229,6 +229,7 @@ int ommmc_host_maxblklen(sdmmc_chipset_h
 intommmc_card_detect(sdmmc_chipset_handle_t);
 intommmc_bus_power(sdmmc_chipset_handle_t, uint32_t);
 intommmc_bus_clock(sdmmc_chipset_handle_t, int);
+int

sdmmc update

2013-11-07 Thread Sylvestre Gallon
Hi tech@

Here is a diff that updates our sdmmc stack with support for
other frequencies than 25Mhz and for 4 pins transfers. Big
chunks of this code comes directly from NetBSD sdmmc stack.

Normally this diff should speedup things for some sdcards and
for some controllers.

I tried this diff on the only sdmmc controller I have (ommmc).
It will be awesome if people could give me feedback for these
drivers :

 rtsx
 sdhc
 imxesdhc
 pxammc
 w83l518d_sdmmc

Any OK/Comments ?

Index: arch/arm/xscale/pxa2x0_mmc.c
===
RCS file: /cvs/src/sys/arch/arm/xscale/pxa2x0_mmc.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 pxa2x0_mmc.c
--- arch/arm/xscale/pxa2x0_mmc.c22 Aug 2012 13:37:04 -  1.11
+++ arch/arm/xscale/pxa2x0_mmc.c6 Nov 2013 16:59:38 -
@@ -56,6 +56,7 @@ u_int32_t pxammc_host_ocr(sdmmc_chipset_
 intpxammc_host_maxblklen(sdmmc_chipset_handle_t);
 intpxammc_card_detect(sdmmc_chipset_handle_t);
 intpxammc_bus_power(sdmmc_chipset_handle_t, u_int32_t);
+intpxammc_bus_width(sdmmc_chipset_handle_t, int);
 intpxammc_bus_clock(sdmmc_chipset_handle_t, int);
 void   pxammc_exec_command(sdmmc_chipset_handle_t, struct sdmmc_command *);
 void   pxammc_clock_stop(struct pxammc_softc *);
@@ -90,6 +91,7 @@ struct sdmmc_chip_functions pxammc_funct
/* bus power and clock frequency */
pxammc_bus_power,
pxammc_bus_clock,
+   pxammc_bus_width,
/* command execution */
pxammc_exec_command
 };
@@ -179,6 +181,8 @@ pxammc_attach(struct pxammc_softc *sc, v
 */
bzero(saa, sizeof saa);
saa.saa_busname = sdmmc;
+   saa.saa_clkmax = SDMMC_SDCLK_25MHZ;
+
saa.sct = pxammc_functions;
saa.sch = sc;
saa.flags = SMF_STOP_AFTER_MULTIPLE;
@@ -274,6 +278,12 @@ pxammc_bus_power(sdmmc_chipset_handle_t 
DPRINTF(0,(%s: driver lacks set_power() function\n,
sc-sc_dev.dv_xname));
return ENXIO;
+}
+
+int
+pxammc_bus_width(sdmmc_chipset_handle_t sch, int width)
+{
+   return (0);
 }
 
 int
Index: arch/armv7/imx/imxesdhc.c
===
RCS file: /cvs/src/sys/arch/armv7/imx/imxesdhc.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 imxesdhc.c
--- arch/armv7/imx/imxesdhc.c   27 Oct 2013 20:27:09 -  1.3
+++ arch/armv7/imx/imxesdhc.c   6 Nov 2013 16:59:43 -
@@ -195,6 +195,7 @@ int imxesdhc_host_maxblklen(sdmmc_chipse
 intimxesdhc_card_detect(sdmmc_chipset_handle_t);
 intimxesdhc_bus_power(sdmmc_chipset_handle_t, uint32_t);
 intimxesdhc_bus_clock(sdmmc_chipset_handle_t, int);
+intimxesdhc_bus_width(sdmmc_chipset_handle_t, int);
 void   imxesdhc_card_intr_mask(sdmmc_chipset_handle_t, int);
 void   imxesdhc_card_intr_ack(sdmmc_chipset_handle_t);
 void   imxesdhc_exec_command(sdmmc_chipset_handle_t, struct sdmmc_command *);
@@ -225,6 +226,7 @@ struct sdmmc_chip_functions imxesdhc_fun
/* bus power and clock frequency */
imxesdhc_bus_power,
imxesdhc_bus_clock,
+   imxesdhc_bus_width,
/* command execution */
imxesdhc_exec_command,
/* card interrupt */
@@ -319,6 +321,7 @@ imxesdhc_attach(struct device *parent, s
 
bzero(saa, sizeof(saa));
saa.saa_busname = sdmmc;
+   saa.saa_clkmax = SDMMC_SDCLK_25MHZ;
saa.sct = imxesdhc_functions;
saa.sch = sc;
 
@@ -327,7 +330,7 @@ imxesdhc_attach(struct device *parent, s
error = 0;
goto err;
}
-   
+
return;
 
 err:
@@ -483,6 +486,12 @@ imxesdhc_card_detect(sdmmc_chipset_handl
  */
 int
 imxesdhc_bus_power(sdmmc_chipset_handle_t sch, uint32_t ocr)
+{
+   return 0;
+}
+
+int
+imxesdhc_bus_width(sdmmc_chipset_handle_t sch, int freq)
 {
return 0;
 }
Index: arch/armv7/omap/ommmc.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/ommmc.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 ommmc.c
--- arch/armv7/omap/ommmc.c 28 Oct 2013 20:45:20 -  1.9
+++ arch/armv7/omap/ommmc.c 6 Nov 2013 16:59:43 -
@@ -228,6 +228,7 @@ int ommmc_host_maxblklen(sdmmc_chipset_h
 intommmc_card_detect(sdmmc_chipset_handle_t);
 intommmc_bus_power(sdmmc_chipset_handle_t, uint32_t);
 intommmc_bus_clock(sdmmc_chipset_handle_t, int);
+intommmc_bus_width(sdmmc_chipset_handle_t, int);
 void   ommmc_card_intr_mask(sdmmc_chipset_handle_t, int);
 void   ommmc_card_intr_ack(sdmmc_chipset_handle_t);
 void   ommmc_exec_command(sdmmc_chipset_handle_t, struct sdmmc_command *);
@@ -259,6 +260,7 @@ struct sdmmc_chip_functions ommmc_functi
/* bus power and clock frequency */
ommmc_bus_power,
ommmc_bus_clock,
+   ommmc_bus_width,
/* command execution */
ommmc_exec_command,
/* card interrupt */
@@ -386,9 +388,10 @@ ommmc_attach(struct device *parent, stru
 

Re: Update the sdmmmc stack to take care of the SMC_CAPS_SINGLE_ONLY capability

2013-10-22 Thread Sylvestre Gallon
On Sat, Oct 19, 2013 at 1:51 PM, Raphael Graf r...@undefined.ch wrote:
 On Fri, October 18, 2013 9:54 am, Sylvestre Gallon wrote:
 Hi tech@

 Here is a diff to allow the sdmmc SMC_CAPS_SINGLE_ONLY caps to do
 something. The bits I take are from NetBSD and it works well with
 ommmc(4) on my Beagle Bone Black.

 This capability force the sdmmc stack to only issue single blocks
 transfers. It is usefull for debug purpose and/or for broken sdmmmc
 controller.

 Any OK/Comments ?

 This looks good to me. I have tested it with ommmc(4), if needed I can
 test with pxammc(4) next week.


If you can give it a try with pxammc(4) it would be awesome :)

Thanks.

-- 
Sylvestre Gallon



Update the sdmmmc stack to take care of the SMC_CAPS_SINGLE_ONLY capability

2013-10-18 Thread Sylvestre Gallon
Hi tech@

Here is a diff to allow the sdmmc SMC_CAPS_SINGLE_ONLY caps to do
something. The bits I take are from NetBSD and it works well with
ommmc(4) on my Beagle Bone Black.

This capability force the sdmmc stack to only issue single blocks
transfers. It is usefull for debug purpose and/or for broken sdmmmc
controller.

Any OK/Comments ?

Cheers,

Index: sdmmc_mem.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_mem.c,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 sdmmc_mem.c
--- sdmmc_mem.c 12 Sep 2013 11:54:04 -  1.17
+++ sdmmc_mem.c 18 Oct 2013 09:31:15 -
@@ -42,6 +42,14 @@ int  sdmmc_mem_mmc_switch(struct sdmmc_fu
 
 intsdmmc_mem_sd_init(struct sdmmc_softc *, struct sdmmc_function *);
 intsdmmc_mem_mmc_init(struct sdmmc_softc *, struct sdmmc_function *);
+intsdmmc_mem_single_read_block(struct sdmmc_function *, int, u_char *,
+   size_t);
+intsdmmc_mem_read_block_subr(struct sdmmc_function *, int, u_char *,
+   size_t);
+intsdmmc_mem_single_write_block(struct sdmmc_function *, int, u_char *,
+   size_t);
+intsdmmc_mem_write_block_subr(struct sdmmc_function *, int, u_char *,
+   size_t);
 
 #ifdef SDMMC_DEBUG
 #define DPRINTF(s) printf s
@@ -551,14 +559,13 @@ sdmmc_mem_set_blocklen(struct sdmmc_soft
 }
 
 int
-sdmmc_mem_read_block(struct sdmmc_function *sf, int blkno, u_char *data,
+sdmmc_mem_read_block_subr(struct sdmmc_function *sf, int blkno, u_char *data,
 size_t datalen)
 {
struct sdmmc_softc *sc = sf-sc;
struct sdmmc_command cmd;
int error;
 
-   rw_enter_write(sc-sc_lock);
 
if ((error = sdmmc_select_card(sc, sf)) != 0)
goto err;
@@ -602,20 +609,53 @@ sdmmc_mem_read_block(struct sdmmc_functi
} while (!ISSET(MMC_R1(cmd.c_resp), MMC_R1_READY_FOR_DATA));
 
 err:
-   rw_exit(sc-sc_lock);
-   return error;
+   return (error);
 }
 
 int
-sdmmc_mem_write_block(struct sdmmc_function *sf, int blkno, u_char *data,
+sdmmc_mem_single_read_block(struct sdmmc_function *sf, int blkno, u_char *data,
+size_t datalen)
+{
+   int error;
+   int i;
+
+   for (i = 0; i  datalen / sf-csd.sector_size; i++) {
+   error = sdmmc_mem_read_block_subr(sf, blkno + i, data + i *
+   sf-csd.sector_size, sf-csd.sector_size);
+   if (error)
+   break;
+   }
+
+   return (error);
+}
+
+int
+sdmmc_mem_read_block(struct sdmmc_function *sf, int blkno, u_char *data,
 size_t datalen)
 {
struct sdmmc_softc *sc = sf-sc;
-   struct sdmmc_command cmd;
int error;
 
rw_enter_write(sc-sc_lock);
 
+   if (ISSET(sc-sc_caps, SMC_CAPS_SINGLE_ONLY)) {
+   error = sdmmc_mem_single_read_block(sf, blkno, data, datalen);
+   } else {
+   error = sdmmc_mem_read_block_subr(sf, blkno, data, datalen);
+   }
+
+   rw_exit(sc-sc_lock);
+   return (error);
+}
+
+int
+sdmmc_mem_write_block_subr(struct sdmmc_function *sf, int blkno, u_char *data,
+size_t datalen)
+{
+   struct sdmmc_softc *sc = sf-sc;
+   struct sdmmc_command cmd;
+   int error;
+
if ((error = sdmmc_select_card(sc, sf)) != 0)
goto err;
 
@@ -657,6 +697,41 @@ sdmmc_mem_write_block(struct sdmmc_funct
} while (!ISSET(MMC_R1(cmd.c_resp), MMC_R1_READY_FOR_DATA));
 
 err:
+   return (error);
+}
+
+int
+sdmmc_mem_single_write_block(struct sdmmc_function *sf, int blkno, u_char 
*data,
+size_t datalen)
+{
+   int error;
+   int i;
+
+   for (i = 0; i  datalen / sf-csd.sector_size; i++) {
+   error = sdmmc_mem_write_block_subr(sf, blkno + i, data + i *
+   sf-csd.sector_size, sf-csd.sector_size);
+   if (error)
+   break;
+   }
+
+   return (error);
+}
+
+int
+sdmmc_mem_write_block(struct sdmmc_function *sf, int blkno, u_char *data,
+size_t datalen)
+{
+   struct sdmmc_softc *sc = sf-sc;
+   int error;
+
+   rw_enter_write(sc-sc_lock);
+
+   if (ISSET(sc-sc_caps, SMC_CAPS_SINGLE_ONLY)) {
+   error = sdmmc_mem_single_write_block(sf, blkno, data, datalen);
+   } else {
+   error = sdmmc_mem_write_block_subr(sf, blkno, data, datalen);
+   }
+
rw_exit(sc-sc_lock);
-   return error;
+   return (error);
 }



Re: three fuse readdir fixes

2013-10-07 Thread Sylvestre Gallon
 1) our dirent entries are now 8 byte aligned
 2) d_type isn't the file's st_mode, but rather a type that can be derived
from the file's mode
 3) the readdir callback should be setting d_off, but to what?  this diff
just assumes fuse-based filesystems can operate with length based
offsets (even though the padding of them is changed by (1) above!); is
this a bug in the FUSE API?

My bad, I forgot to set d_off when implementing the fuse_fill_readdir.

 4) (no binary change) if the file type is unknown, use DT_UNKNOWN
explictly instead of assuming that's equal to zero

 (Do FUSE filesystems just not support telldir/seekdir?)

The GNU libfuse seems to not handle them. But we can fix our lib to fix that.


 oks?

You're diff works for me OK syl@


-- 
Sylvestre Gallon



Re: fill /* TODO: 11A */ in bwi_rf_set_chan()

2013-09-19 Thread Sylvestre Gallon
On Thu, Sep 19, 2013 at 4:06 PM, Martin Pieuchot mpieuc...@nolizard.org wrote:
 If I'm not mistaken the linux b43 driver uses another version of the
 firmware (v4+).  But bwi(4) is a rewrite/port of what's now the
 b43legacy driver which depends on a firmware (v3) that does not
 support 11A phy.

 So I'm not sure it makes sense to port code from the b43 driver.

If I am not mistaken Linux only uses b43legacy for BCM4306 Rev 2 and
cards that have only 802.11b [1]. These chips are the last ones that
Linux cannot succeed to switch to the firmware v4+. All others use the
b43 driver. But the drivers are very similar.

b43legacy seems to not support phya and the b43 code for phyg is the
same that is used for b43legacy on phyg and phyb. I was thinking that
taking the phya initialization code was not risky.

With these diffs I was trying to start adding each piece of code that
performs phy initialization in b43 that are not present b43legacy (if
these pieces don't break bwi). It should help us to switch to v4+ in
the future with minimum pain. I think that with some work we could mix
what is done b43 and b43legacy in bwi and load the good firmware(v3 or
v4+) depending on the hardware ids. But I should probably come back
with a stack of diffs when I've got some results going forward in this
direction :)

Cheers,

[1] http://wireless.kernel.org/en/users/Drivers/b43

-- 
Sylvestre Gallon



fill /* TODO: 11A */ in bwi_rf_set_chan()

2013-09-09 Thread Sylvestre Gallon
Hi tech@,

Here is a patch that implement the phy_mode == IEEE80211_MODE_11A
part of bwi_rf_set_chan(). It is based on the linux b43/phy_a.c 
switch_channel code.

It does not break my BCM4306. It would be awesome if someone could
try it with a card that have a 11A phy.

Comments/OK/NOK ?

Cheers,

Index: bwi.c
===
RCS file: /cvs/src/sys/dev/ic/bwi.c,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 bwi.c
--- bwi.c   31 Dec 2012 10:07:51 -  1.97
+++ bwi.c   9 Sep 2013 08:42:08 -
@@ -214,6 +214,7 @@ int  bwi_rf_lo_isused(struct bwi_mac *,
 voidbwi_rf_write(struct bwi_mac *, uint16_t, uint16_t);
 uint16_tbwi_rf_read(struct bwi_mac *, uint16_t);
 int bwi_rf_attach(struct bwi_mac *);
+uint16_tbwi_rf_freq_r3a_value(uint16_t);
 voidbwi_rf_set_chan(struct bwi_mac *, uint, int);
 voidbwi_rf_get_gains(struct bwi_mac *);
 voidbwi_rf_init(struct bwi_mac *);
@@ -3875,10 +3876,34 @@ bwi_rf_attach(struct bwi_mac *mac)
return (0);
 }
 
+uint16_t
+bwi_rf_freq_r3a_value(uint16_t freq)
+{
+   if (freq  5091)
+   return (0x40);
+   else if (freq  5321)
+   return (0x0);
+   else if (freq  5806)
+   return (0x80);
+
+   return (0x40);
+}
+
 void
 bwi_rf_set_chan(struct bwi_mac *mac, uint chan, int work_around)
 {
+#define SET_CHAN_DATAH_MAX 5
+#define SET_CHAN_DATAL_MAX 5
struct bwi_softc *sc = mac-mac_sc;
+   struct bwi_phy *phy = mac-mac_phy;
+   uint16_t freq;
+   uint16_t r8;
+   int i, j;
+
+   static const uint8_t datah[SET_CHAN_DATAH_MAX] =
+   { 0x0, 0x40, 0x80, 0x90, 0xd0 };
+   static const uint8_t datal[SET_CHAN_DATAL_MAX] =
+   { 0x0, 0x1, 0x5, 0x6, 0xa };
 
if (chan == IEEE80211_CHAN_ANY)
return;
@@ -3886,23 +3911,69 @@ bwi_rf_set_chan(struct bwi_mac *mac, uin
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_CHAN, chan);
 
/* TODO: 11A */
+   switch (phy-phy_mode) {
+   case IEEE80211_MODE_11A:
+   freq = BWI_RF_2GHZ_CHAN(chan);
+   CSR_WRITE_2(sc, BWI_RF_CHAN, freq);
 
-   if (work_around)
-   bwi_rf_workaround(mac, chan);
+   r8 = CSR_READ_2(sc, 0x8);
+   RF_WRITE(mac, 0x8, r8);
+   RF_SETBITS(mac, 0x2e, 0x0080);
 
-   CSR_WRITE_2(sc, BWI_RF_CHAN, BWI_RF_2GHZ_CHAN(chan));
+   /*
+* r8 = (((freq * 15 * 0xE1FC780F)  32) / 29)  0x0f
+*= freq * 0.025862
+*/
+   if (freq = 4920  freq = 5500)
+   r8 = 3 * freq / 116; /* is equal to r8 = freq * 
0.025862 */
 
-   if (chan == 14) {
-   if (sc-sc_locale == BWI_SPROM_LOCALE_JAPAN)
-   HFLAGS_CLRBITS(mac, BWI_HFLAG_NOT_JAPAN);
-   else
-   HFLAGS_SETBITS(mac, BWI_HFLAG_NOT_JAPAN);
-   CSR_SETBITS_2(sc, BWI_RF_CHAN_EX, (1  11)); /* XXX */
-   } else {
-   CSR_CLRBITS_2(sc, BWI_RF_CHAN_EX, 0x840); /* XXX */
-   }
-   DELAY(8000);/* DELAY(2000); */
+   RF_WRITE(mac, 0x7, (r8  4) | r8);
+   RF_WRITE(mac, 0x20, (r8  4) | r8);
+   RF_WRITE(mac, 0x21, (r8  4) | r8);
+   RF_FILT_SETBITS(mac, 0x22, 0x000f, (r8  4));
+   RF_WRITE(mac, 0x2a, (r8  4));
+   RF_WRITE(mac, 0x2b, (r8  4));
+   RF_FILT_SETBITS(mac, 0x8, 0x00f0, r8  4);
+   RF_FILT_SETBITS(mac, 0x29, 0xff0f, 0x00b0);
+   RF_WRITE(mac, 0x35, 0xaa);
+   RF_WRITE(mac, 0x36, 0x85);
+   RF_FILT_SETBITS(mac, 0x3a, 0xff20, bwi_rf_freq_r3a_value(freq));
+   RF_CLRBITS(mac, 0x3d, 0xff00);
+   RF_FILT_SETBITS(mac, 0x81,  0xff7f, 0x0080);
+   RF_CLRBITS(mac, 0x35, 0x0010);
+   RF_FILT_SETBITS(mac, 0x35, 0xffef, 0x0010);
+
+   r8 = RF_READ(mac, 0x1e);
+   for (i = 0 ; i  5 ; i++)
+   for (j = 0 ; j  5 ; j++)
+   if (r8 == (datah[i]  4 | datal[j])) {
+   CSR_WRITE_2(sc, 0x0069, (i - j)  8 | 
0x00c0);
+   goto end;
+   }
+   break;
+   case IEEE80211_MODE_11B:
+   case IEEE80211_MODE_11G:
+   if (work_around)
+   bwi_rf_workaround(mac, chan);
 
+   CSR_WRITE_2(sc, BWI_RF_CHAN, BWI_RF_2GHZ_CHAN(chan));
+
+   if (chan == 14) {
+   if (sc-sc_locale == BWI_SPROM_LOCALE_JAPAN)
+   HFLAGS_CLRBITS(mac, BWI_HFLAG_NOT_JAPAN);
+   else
+   HFLAGS_SETBITS(mac, BWI_HFLAG_NOT_JAPAN);
+   CSR_SETBITS_2(sc, 

update bwi_mac_dummy_xmit

2013-09-09 Thread Sylvestre Gallon
Hi tech@

Here is a patch to update bwi_mac_dummy_xmit. This diff remove the
differencies with the linux b43_dummy_transmission function.

It works fine with my Broadcom BCM4306 (ID 4320) and it would be awesome if
someone could try it on another chip (or if someone could lend me some
bwi chips).

Comments/OK/NOK ?

Cheers,

Index: bwi.c
===
RCS file: /cvs/src/sys/dev/ic/bwi.c,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 bwi.c
--- bwi.c   31 Dec 2012 10:07:51 -  1.97
+++ bwi.c   9 Sep 2013 16:26:19 -
@@ -148,7 +148,7 @@ void bwi_mac_set_tpctl_11bg(struct bwi
 const struct bwi_tpctl *);
 int bwi_mac_test(struct bwi_mac *);
 voidbwi_mac_setup_tpctl(struct bwi_mac *);
-voidbwi_mac_dummy_xmit(struct bwi_mac *);
+voidbwi_mac_dummy_xmit(struct bwi_mac *, int);
 voidbwi_mac_init_tpctl_11bg(struct bwi_mac *);
 voidbwi_mac_detach(struct bwi_mac *);
 int bwi_get_firmware(const char *, const uint8_t *, size_t,
@@ -1495,7 +1495,7 @@ back:
 }
 
 void
-bwi_mac_dummy_xmit(struct bwi_mac *mac)
+bwi_mac_dummy_xmit(struct bwi_mac *mac, int ofdm)
 {
 #define PACKET_LEN 5
struct bwi_softc *sc = mac-mac_sc;
@@ -1509,23 +1509,24 @@ bwi_mac_dummy_xmit(struct bwi_mac *mac)
static const uint32_t   packet_11bg[PACKET_LEN] =
{ 0x000b846e, 0x00d4, 0x, 0x0100, 0x };
 
-   if (mac-mac_phy.phy_mode == IEEE80211_MODE_11A) {
+   if (ofdm) {
wait_max = 30;
packet = packet_11a;
-   val_50c = 1;
+   val_50c = 0x41;
} else {
wait_max = 250;
packet = packet_11bg;
-   val_50c = 0;
+   val_50c = 0x40;
}
 
for (i = 0; i  PACKET_LEN; ++i)
TMPLT_WRITE_4(mac, i * 4, packet[i]);
 
-   CSR_READ_4(sc, BWI_MAC_STATUS); /* dummy read */
-
CSR_WRITE_2(sc, 0x568, 0);
-   CSR_WRITE_2(sc, 0x7c0, 0);
+   if (mac-mac_rev  11)
+   CSR_WRITE_2(sc, 0x7c0, 0);
+   else
+   CSR_WRITE_2(sc, 0x7c0, 0x100);
CSR_WRITE_2(sc, 0x50c, val_50c);
CSR_WRITE_2(sc, 0x508, 0);
CSR_WRITE_2(sc, 0x50a, 0);
@@ -1534,6 +1535,7 @@ bwi_mac_dummy_xmit(struct bwi_mac *mac)
CSR_WRITE_2(sc, 0x568, 0x826);
CSR_WRITE_2(sc, 0x500, 0);
CSR_WRITE_2(sc, 0x502, 0x30);
+   CSR_READ_2(sc, 0x502);  /* dummy read */
 
if (rf-rf_type == BWI_RF_T_BCM2050  rf-rf_rev = 5)
RF_WRITE(mac, 0x51, 0x17);
@@ -1548,7 +1550,7 @@ bwi_mac_dummy_xmit(struct bwi_mac *mac)
break;
DELAY(10);
}
-   for (i = 0; i  10; ++i) {
+   for (i = 0; i  0x19; ++i) {
if ((CSR_READ_2(sc, 0x690)  0x100) == 0)
break;
DELAY(10);
@@ -1607,7 +1609,7 @@ bwi_mac_init_tpctl_11bg(struct bwi_mac *
bwi_mac_set_tpctl_11bg(mac, tpctl);
}
 
-   bwi_mac_dummy_xmit(mac);
+   bwi_mac_dummy_xmit(mac, 0);
 
mac-mac_flags |= BWI_MAC_F_TPCTL_INITED;
rf-rf_base_tssi = PHY_READ(mac, 0x29);
@@ -3687,7 +3689,7 @@ bwi_set_gains(struct bwi_mac *mac, const
PHY_FILT_SETBITS(mac, 0x4a1, 0xbfbf, phy_gain1);
PHY_FILT_SETBITS(mac, 0x4a2, 0xbfbf, phy_gain2);
}
-   bwi_mac_dummy_xmit(mac);
+   bwi_mac_dummy_xmit(mac, 0);
 }
 
 void
@@ -4833,7 +4835,7 @@ bwi_rf_lo_update_11g(struct bwi_mac *mac
if (phy-phy_flags  BWI_PHY_F_LINKED) {
PHY_WRITE(mac, 0x429, regs.phy_429  0x7fff);
PHY_WRITE(mac, 0x802, regs.phy_802  0xfffc);
-   bwi_mac_dummy_xmit(mac);
+   bwi_mac_dummy_xmit(mac, 0);
}
RF_WRITE(mac, 0x43, 0x6);
 



updating bwi_tbl_ helpers.

2013-09-09 Thread Sylvestre Gallon
Hi tech@

Here is a diff to update bwi_tbl_write_{2|4} functions and to add 
bwi_tbl_read_{2|4}. Switching these functions parameters from 
addr, data to addr, index, data will be more natural and will 
simplify diffs with the linux driver.

I take example on tables.c code in the b43 driver. Like the 2 
other diffs I've sent few minutes ago it works for me and it will
be great to have feedback on other cards.

Comments/OK/NOK ?

Cheers,

Index: bwi.c
===
RCS file: /cvs/src/sys/dev/ic/bwi.c,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 bwi.c
--- bwi.c   31 Dec 2012 10:07:51 -  1.97
+++ bwi.c   9 Sep 2013 12:07:45 -
@@ -191,8 +191,10 @@ uint16_tbwi_phy_read(struct bwi_mac *,
 int bwi_phy_attach(struct bwi_mac *);
 voidbwi_phy_set_bbp_atten(struct bwi_mac *, uint16_t);
 int bwi_phy_calibrate(struct bwi_mac *);
-voidbwi_tbl_write_2(struct bwi_mac *mac, uint16_t, uint16_t);
-voidbwi_tbl_write_4(struct bwi_mac *mac, uint16_t, uint32_t);
+uint16_tbwi_tbl_read_2(struct bwi_mac *, uint16_t, uint16_t);
+uint32_tbwi_tbl_read_4(struct bwi_mac *, uint16_t, uint16_t);
+voidbwi_tbl_write_2(struct bwi_mac *, uint16_t, uint16_t, 
uint16_t);
+voidbwi_tbl_write_4(struct bwi_mac *, uint16_t, uint16_t, 
uint32_t);
 voidbwi_nrssi_write(struct bwi_mac *, uint16_t, int16_t);
 int16_t bwi_nrssi_read(struct bwi_mac *, uint16_t);
 voidbwi_phy_init_11a(struct bwi_mac *);
@@ -2855,6 +2857,8 @@ bwi_phy_attach(struct bwi_mac *mac)
 * Verify whether the revision of the PHY type is supported
 * Convert PHY type to ieee80211_phymode
 */
+   phy-phy_tbl_dir = BWI_TBL_DIR_UNKNOWN;
+   phy-phy_tbl_addr = 0;
switch (phytype) {
case BWI_PHYINFO_TYPE_11A:
if (phyrev = 4) {
@@ -2864,9 +2868,6 @@ bwi_phy_attach(struct bwi_mac *mac)
}
phy-phy_init = bwi_phy_init_11a;
phy-phy_mode = IEEE80211_MODE_11A;
-   phy-phy_tbl_ctrl = BWI_PHYR_TBL_CTRL_11A;
-   phy-phy_tbl_data_lo = BWI_PHYR_TBL_DATA_LO_11A;
-   phy-phy_tbl_data_hi = BWI_PHYR_TBL_DATA_HI_11A;
break;
case BWI_PHYINFO_TYPE_11B:
for (i = 0; i  nitems(bwi_sup_bphy); ++i) {
@@ -2890,9 +2891,6 @@ bwi_phy_attach(struct bwi_mac *mac)
}
phy-phy_init = bwi_phy_init_11g;
phy-phy_mode = IEEE80211_MODE_11G;
-   phy-phy_tbl_ctrl = BWI_PHYR_TBL_CTRL_11G;
-   phy-phy_tbl_data_lo = BWI_PHYR_TBL_DATA_LO_11G;
-   phy-phy_tbl_data_hi = BWI_PHYR_TBL_DATA_HI_11G;
break;
default:
printf(%s: unsupported PHY type %d\n,
@@ -2947,27 +2945,77 @@ bwi_phy_calibrate(struct bwi_mac *mac)
return (0);
 }
 
+uint16_t
+bwi_tbl_read_2(struct bwi_mac *mac, uint16_t tbl, uint16_t ofs)
+{
+   struct bwi_phy *phy = mac-mac_phy;
+   uint16_t addr;
+
+   addr = tbl + ofs;
+   if ((phy-phy_tbl_dir != BWI_TBL_DIR_READ) 
+   (addr - 1 != phy-phy_tbl_addr)) {
+   PHY_WRITE(mac, BWI_PHYR_TBL_CTRL_11G, addr);
+   phy-phy_tbl_dir = BWI_TBL_DIR_READ;
+   }
+
+   phy-phy_tbl_addr = addr;
+   return (PHY_READ(mac, BWI_PHYR_TBL_DATA_LO_11G));
+}
+
+uint32_t
+bwi_tbl_read_4(struct bwi_mac *mac, uint16_t tbl, uint16_t ofs)
+{
+   struct bwi_phy *phy = mac-mac_phy;
+   uint16_t addr;
+   uint32_t val;
+
+   addr = tbl + ofs;
+   if ((phy-phy_tbl_dir != BWI_TBL_DIR_READ) 
+   (addr - 1 != phy-phy_tbl_addr)) {
+   PHY_WRITE(mac, BWI_PHYR_TBL_CTRL_11G, addr);
+   phy-phy_tbl_dir = BWI_TBL_DIR_READ;
+   }
+
+   phy-phy_tbl_addr = addr;
+   val = PHY_READ(mac, BWI_PHYR_TBL_DATA_HI_11G);
+   val = 16;
+   val |= PHY_READ(mac, BWI_PHYR_TBL_DATA_LO_11G);
+   return (val);
+}
+
 void
-bwi_tbl_write_2(struct bwi_mac *mac, uint16_t ofs, uint16_t data)
+bwi_tbl_write_2(struct bwi_mac *mac, uint16_t tbl, uint16_t ofs, uint16_t data)
 {
struct bwi_phy *phy = mac-mac_phy;
+   uint16_t addr;
 
-   KASSERT(phy-phy_tbl_ctrl != 0  phy-phy_tbl_data_lo != 0);
-   PHY_WRITE(mac, phy-phy_tbl_ctrl, ofs);
-   PHY_WRITE(mac, phy-phy_tbl_data_lo, data);
+   addr = tbl + ofs;
+   if ((phy-phy_tbl_dir != BWI_TBL_DIR_WRITE) 
+   (addr - 1 != phy-phy_tbl_addr)) {
+   PHY_WRITE(mac, BWI_PHYR_TBL_CTRL_11G, addr);
+   phy-phy_tbl_dir = BWI_TBL_DIR_WRITE;
+   }
+
+   phy-phy_tbl_addr = addr;
+   PHY_WRITE(mac, BWI_PHYR_TBL_DATA_LO_11G, data);
 }
 
 void
-bwi_tbl_write_4(struct bwi_mac *mac, uint16_t ofs, uint32_t data)
+bwi_tbl_write_4(struct bwi_mac *mac, uint16_t tbl, uint16_t ofs, uint32_t data)
 {
struct bwi_phy *phy = 

Advanced btcoex in iwn(4)

2013-08-10 Thread Sylvestre Gallon
Hi,

Here is a patch for advanced btcoex support in iwn(4). I know
that there is no particular reason to do it due to the lack of
bluetooth enabled by default. But as we already do btcoex for
the cards without IWN_FLAG_ADV_BT_COEX flag I was thinking
that we could also do it on other cards.

I take all these things in freebsd without the memset that
overflow:
memset(btprot, 0, sizeof btprio);

I've also replaced some hardcoded values by defines and added
few comments.

It works on Intel Wifi Link 130 and jca@ have tried it
on his Wifi Link 5300. It would be awesome if someone could 
try it on other chips.

Any ok or this code this is really not needed ?

Cheers,

Index: sys/dev/pci//if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.121
diff -u -p -u -p -r1.121 if_iwn.c
--- sys/dev/pci//if_iwn.c   7 Aug 2013 01:06:35 -   1.121
+++ sys/dev/pci//if_iwn.c   7 Aug 2013 13:43:35 -
@@ -208,6 +208,7 @@ int iwn_send_sensitivity(struct iwn_sof
 intiwn_set_pslevel(struct iwn_softc *, int, int, int);
 intiwn_send_temperature_offset(struct iwn_softc *);
 intiwn_send_btcoex(struct iwn_softc *);
+intiwn_send_advanced_btcoex(struct iwn_softc *);
 intiwn5000_runtime_calib(struct iwn_softc *);
 intiwn_config(struct iwn_softc *);
 intiwn_scan(struct iwn_softc *, uint16_t);
@@ -4146,6 +4147,65 @@ iwn_send_btcoex(struct iwn_softc *sc)
 }
 
 int
+iwn_send_advanced_btcoex(struct iwn_softc *sc)
+{
+   static const uint32_t btcoex_3wire[12] = {
+   0x, 0x, 0xaeaa, 0x,
+   0xcc00ff28, 0x, 0xcc00, 0x,
+   0xc0004000, 0x4000, 0xf0005000, 0xf0005000,
+   };
+   struct iwn6000_btcoex_config btconfig;
+   struct iwn_btcoex_priotable btprio;
+   struct iwn_btcoex_prot btprot;
+   int error, i;
+
+   memset(btconfig, 0, sizeof btconfig);
+   btconfig.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION |
+   (IWN_BT_FLAG_COEX6000_MODE_3W  IWN_BT_FLAG_COEX6000_MODE_SHIFT) |
+   IWN_BT_FLAG_SYNC_2_BT_DISABLE;
+   btconfig.max_kill = 5;
+   btconfig.bt3_t7_timer = 1;
+   btconfig.kill_ack = htole32(0x);
+   btconfig.kill_cts = htole32(0x);
+   btconfig.sample_time = 2;
+   btconfig.bt3_t2_timer = 0xc;
+   for (i = 0; i  12; i++)
+   btconfig.lookup_table[i] = htole32(btcoex_3wire[i]);
+   btconfig.valid = htole16(0xff);
+   btconfig.prio_boost = 0xf0;
+   DPRINTF((configuring advanced bluetooth coexistence\n));
+   error = iwn_cmd(sc, IWN_CMD_BT_COEX, btconfig, sizeof(btconfig), 1);
+   if (error != 0)
+   return (error);
+
+   memset(btprio, 0, sizeof btprio);
+   btprio.calib_init1 = 0x6;
+   btprio.calib_init2 = 0x7;
+   btprio.calib_periodic_low1 = 0x2;
+   btprio.calib_periodic_low2 = 0x3;
+   btprio.calib_periodic_high1 = 0x4;
+   btprio.calib_periodic_high2 = 0x5;
+   btprio.dtim = 0x6;
+   btprio.scan52 = 0x8;
+   btprio.scan24 = 0xa;
+   error = iwn_cmd(sc, IWN_CMD_BT_COEX_PRIOTABLE, btprio, sizeof(btprio),
+   1);
+   if (error != 0)
+   return (error);
+
+   /* Force BT state machine change */
+   memset(btprot, 0, sizeof btprot);
+   btprot.open = 1;
+   btprot.type = 1;
+   error = iwn_cmd(sc, IWN_CMD_BT_COEX_PROT, btprot, sizeof(btprot), 1);
+   if (error != 0)
+   return (error);
+
+   btprot.open = 0;
+   return (iwn_cmd(sc, IWN_CMD_BT_COEX_PROT, btprot, sizeof(btprot), 1));
+}
+
+int
 iwn5000_runtime_calib(struct iwn_softc *sc)
 {
struct iwn5000_calib_config cmd;
@@ -4202,15 +4262,14 @@ iwn_config(struct iwn_softc *sc)
}
 
/* Configure bluetooth coexistence. */
-   if (sc-sc_flags  IWN_FLAG_ADV_BT_COEX) {
-   /* XXX Advanced bluetooth coexistence isn't implemented yet. */
-   } else {
+   if (sc-sc_flags  IWN_FLAG_ADV_BT_COEX)
+   error = iwn_send_advanced_btcoex(sc);
+   else
error = iwn_send_btcoex(sc);
-   if (error != 0) {
-   printf(%s: could not configure bluetooth 
coexistence\n,
-   sc-sc_dev.dv_xname);
-   return error;
-   }
+   if (error != 0) {
+   printf(%s: could not configure bluetooth coexistence\n,
+   sc-sc_dev.dv_xname);
+   return error;
}
 
/* Set mode, channel, RX filter and enable RX. */
Index: sys/dev/pci//if_iwnreg.h
===
RCS file: /cvs/src/sys/dev/pci/if_iwnreg.h,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 if_iwnreg.h
--- sys/dev/pci//if_iwnreg.h1 Sep 2011 18:49:56 -   1.43

Add Intel Centrino Wireless-N 130 support for iwn

2013-08-07 Thread Sylvestre Gallon
Hi tech@

Here is a diff to allow the iwn driver to work with the intel Wifi Link
130. It works for me(tm) without problems and solve this bug report : 

http://marc.info/?|=openbsd-bugsm=134586079532510w=2

Any OK ?

Cheers,

Index: sys/dev/pci/if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.121
diff -u -p -u -p -r1.121 if_iwn.c
--- sys/dev/pci/if_iwn.c7 Aug 2013 01:06:35 -   1.121
+++ sys/dev/pci/if_iwn.c7 Aug 2013 09:25:43 -
@@ -90,6 +90,8 @@ static const struct pci_matchid iwn_devi
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_1030_2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_100_1 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_100_2 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_130_1 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_130_2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_1 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_2 },
 };
@@ -639,12 +641,8 @@ iwn5000_attach(struct iwn_softc *sc, pci
break;
case IWN_HW_REV_TYPE_6005:
sc-limits = iwn6000_sensitivity_limits;
-   if (pid == PCI_PRODUCT_INTEL_WL_1030_1 ||
-   pid == PCI_PRODUCT_INTEL_WL_1030_2 ||
-   pid == PCI_PRODUCT_INTEL_WL_6030_1 ||
-   pid == PCI_PRODUCT_INTEL_WL_6030_2 ||
-   pid == PCI_PRODUCT_INTEL_WL_6235_1 ||
-   pid == PCI_PRODUCT_INTEL_WL_6235_2) {
+   if (pid != PCI_PRODUCT_INTEL_WL_6005_1 
+   pid != PCI_PRODUCT_INTEL_WL_6005_2) {
sc-fwname = iwn-6030;
sc-sc_flags |= IWN_FLAG_ADV_BT_COEX;
} else



sysctl fix

2013-06-06 Thread Sylvestre Gallon
Hi tech@

I was currently trying to get the fuse sysctls working when I found a bug
in sbin/sysctl.c

If you look at sys/kern/vfs_init.c MOUNT_FUSEFS use the biggest typenum : 18.
So when the function vfsinit in sbin/sysctl.c gets VFS_MAXTYPENUM it gets 
18, but this value will never be reached in the for statement...

I jump on the occasion to remove all compilation warnings for sysctl.

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 12:07:38 -
@@ -268,7 +268,8 @@ void
 listall(char *prefix, struct list *lp)
 {
char *cp, name[BUFSIZ];
-   int lvl2, len;
+   size_t len;
+   int lvl2;
 
if (lp-list == NULL)
return;
@@ -861,7 +862,7 @@ parse(char *string, int flags)
}
if (special  RNDSTATS) {
struct rndstats *rndstats = (struct rndstats *)buf;
-   int i;
+   size_t i;
 
if (!nflag)
(void)printf(%s%s, string, equ);
@@ -1025,7 +1026,7 @@ parse_ports(char *portspec, int *port, i
 
 void
 parse_baddynamic(int mib[], size_t len, char *string, void **newvalp,
-size_t *newsizep, int flags, int nflag)
+size_t *newsizep, int flags, int nf)
 {
static u_int32_t newbaddynamic[DP_MAPSIZE];
int port, high_port, baddynamic_loaded = 0, full_list_set = 0;
@@ -1043,7 +1044,7 @@ parse_baddynamic(int mib[], size_t len, 
size, 0, 0) == -1) {
if (flags == 0)
return;
-   if (!nflag)
+   if (!nf)
printf(%s: , string);
puts(kernel does contain bad dynamic 
port tables);
@@ -1138,8 +1139,8 @@ vfsinit(void)
}
mib[2] = VFS_CONF;
buflen = sizeof vfc;
-   for (loc = lastused, cnt = 1; cnt  maxtypenum; cnt++) {
-   mib[3] = cnt - 1;
+   for (loc = lastused, cnt = 0; cnt  maxtypenum; cnt++) {
+   mib[3] = cnt;
if (sysctl(mib, 4, vfc, buflen, (void *)0, (size_t)0)  0) {
if (errno == EOPNOTSUPP)
continue;
@@ -1280,13 +1281,13 @@ sysctl_bios(char *string, char **bufpp, 
mib[2] = indx;
if (indx == BIOS_DISKINFO) {
if (*bufpp == NULL) {
-   char name[BUFSIZ];
+   char str[BUFSIZ];
 
/* scan all the bios devices */
for (indx = 0; indx  256; indx++) {
-   snprintf(name, sizeof(name), %s.%u,
+   snprintf(str, sizeof(str), %s.%u,
string, indx);
-   parse(name, 1);
+   parse(str, 1);
}
return (-1);
}
@@ -1782,10 +1783,10 @@ sysctl_forkstat(char *string, char **buf
 int
 sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   int indx, stor, i;
+   int indx, stor;
char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
struct list lp;
-   size_t size;
+   size_t size, i;
 
if (*bufpp == NULL) {
listall(string, kernmalloclist);
@@ -2282,7 +2283,7 @@ sysctl_tc(char *string, char **bufpp, in
 int
 sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   char *devname, *typename;
+   char *name, *typename;
int dev, numt, i;
enum sensor_type type;
struct sensordev snsrdev;
@@ -2312,7 +2313,7 @@ sysctl_sensors(char *string, char **bufp
 * provided below hw.sensors tree.
 * The first branch of hw.sensors tree is the device name.
 */
-   if ((devname = strsep(bufpp, .)) == NULL) {
+   if ((name = strsep(bufpp, .)) == NULL) {
warnx(%s: incomplete specification, string);
return (-1);
}
@@ -2325,11 +2326,11 @@ sysctl_sensors(char *string, char **bufp
if (errno == ENOENT)
break;
}
-   if (strcmp(devname, snsrdev.xname) == 0)
+   if (strcmp(name, snsrdev.xname) == 0)
break;
}
-   if (strcmp(devname, snsrdev.xname) != 0) {
-   warnx(%s: sensor device not found: %s, string, devname);
+   if (strcmp(name, snsrdev.xname) != 0) {
+   warnx(%s: sensor device not found: %s, string, name);
return (-1);
}
if (*bufpp == 

Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
On Thu, Jun 6, 2013 at 4:39 PM, Alexey E. Suslikov
alexey.susli...@gmail.com wrote:
 int  emulcmp(const void *, const void *);

using WARNINGS=yes make it remove the following warning :

sysctl.c:2697: warning: no previous prototype for 'emulcmp'

Cheers,


--
Sylvestre Gallon



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
Hi,

Sorry for the last mistakes. Here is a new diff that allow the
maxtypenum to be reached.

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 21:19:32 -
@@ -1138,8 +1138,8 @@ vfsinit(void)
}
mib[2] = VFS_CONF;
buflen = sizeof vfc;
-   for (loc = lastused, cnt = 1; cnt  maxtypenum; cnt++) {
-   mib[3] = cnt - 1;
+   for (loc = lastused, cnt = 0; cnt  maxtypenum; cnt++) {
+   mib[3] = cnt;
if (sysctl(mib, 4, vfc, buflen, (void *)0, (size_t)0)  0) {
if (errno == EOPNOTSUPP)
continue;



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
Here is a second one to add fuse sysctls.

Cheers,

Index: sys/miscfs/fuse/fusefs.h
===
RCS file: /cvs/src/sys/miscfs/fuse/fusefs.h,v
retrieving revision 1.1
diff -u -p -r1.1 fusefs.h
--- sys/miscfs/fuse/fusefs.h3 Jun 2013 15:50:56 -   1.1
+++ sys/miscfs/fuse/fusefs.h6 Jun 2013 21:41:36 -
@@ -18,6 +18,23 @@
 #ifndef __FUSEFS_H__
 #define __FUSEFS_H__
 
+/* sysctl defines */
+#define FUSEFS_NB_OPENDEVS 1   /* # of fuse devices opened */
+#define FUSEFS_INFBUFS 2   /* # of in fbufs */
+#define FUSEFS_WAITFBUFS   3   /* # of fbufs waiting for a response */
+#define FUSEFS_POOL_NBPAGES4   /* # total fusefs size */
+#define FUSEFS_MAXID   5   /* number of valid fusefs ids */
+
+#define FUSEFS_NAMES { \
+   { 0, 0}, \
+   { fusefs_open_devices, CTLTYPE_INT }, \
+   { fusefs_fbufs_in, CTLTYPE_INT }, \
+   { fusefs_fbufs_wait, CTLTYPE_INT }, \
+   { fusefs_pool_pages, CTLTYPE_INT }, \
+}
+
+#ifdef  _KERNEL
+
 struct fuse_msg;
 
 struct fusefs_mnt {
@@ -42,21 +59,6 @@ struct fusefs_mnt {
 extern struct vops fusefs_vops;
 extern struct pool fusefs_fbuf_pool;
 
-/* sysctl defines */
-#define FUSEFS_NB_OPENDEVS 1   /* # of fuse devices opened */
-#define FUSEFS_INFBUFS 2   /* # of in fbufs */
-#define FUSEFS_WAITFBUFS   3   /* # of fbufs waiting for a response */
-#define FUSEFS_POOL_NBPAGES4   /* # total fusefs size */
-#define FUSEFS_MAXID   5   /* number of valid fusefs ids */
-
-#define FUSEFS_NAMES { \
-   { 0, 0}, \
-   { fusefs_open_devices, CTLTYPE_INT }, \
-   { fusefs_fbufs_in, CTLTYPE_INT }, \
-   { fusefs_fbufs_wait, CTLTYPE_INT }, \
-   { fusefs_pool_pages, CTLTYPE_INT }, \
-}
-
 /* fuse helpers */
 #define TSLEEP_TIMEOUT 5
 void update_vattr(struct mount *mp, struct vattr *v);
@@ -82,4 +84,5 @@ void fuse_device_set_fmp(struct fusefs_m
 /* #define FUSE_DEBUG_VNOP
 #define FUSE_DEBUG */
 
+#endif /* _KERNEL */
 #endif /* __FUSEFS_H__ */
Index: sbin/sysctl/sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -r1.189 sysctl.c
--- sbin/sysctl/sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sbin/sysctl/sysctl.c6 Jun 2013 21:41:37 -
@@ -88,6 +88,8 @@
 #include ufs/ufs/inode.h
 #include ufs/ffs/ffs_extern.h
 
+#include miscfs/fuse/fusefs.h
+
 #include nfs/nfsproto.h
 #include nfs/nfs.h
 
@@ -1103,6 +1105,7 @@ debuginit(void)
 struct ctlname vfsgennames[] = CTL_VFSGENCTL_NAMES;
 struct ctlname ffsname[] = FFS_NAMES;
 struct ctlname nfsname[] = FS_NFS_NAMES;
+struct ctlname fusefsname[] = FUSEFS_NAMES;
 struct list *vfsvars;
 int *vfs_typenums;
 
@@ -1156,6 +1159,10 @@ vfsinit(void)
if (!strcmp(vfc.vfc_name, MOUNT_NFS)) {
vfsvars[cnt].list = nfsname;
vfsvars[cnt].size = NFS_MAXID;
+   }
+   if (!strcmp(vfc.vfc_name, MOUNT_FUSEFS)) {
+   vfsvars[cnt].list = fusefsname;
+   vfsvars[cnt].size = FUSEFS_MAXID;
}
vfs_typenums[cnt] = vfc.vfc_typenum;
strlcat(names[loc], vfc.vfc_name, sizeof names - loc);
Index: sbin/sysctl/sysctl.8
===
RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
retrieving revision 1.169
diff -u -p -r1.169 sysctl.8
--- sbin/sysctl/sysctl.82 Jun 2013 21:37:03 -   1.169
+++ sbin/sysctl/sysctl.86 Jun 2013 21:41:37 -
@@ -399,6 +399,10 @@ and a few require a kernel compiled with
 .It vfs.ffs.dirhash_maxmem Ta integer Ta yes
 .It vfs.ffs.dirhash_mem Ta integer Ta no
 .It vfs.nfs.iothreads Ta integer Ta yes
+.It vfs.fuse.fusefs_open_devices Ta integer Ta no
+.It vfs.fuse.fusefs_fbufs_in Ta integer Ta no
+.It vfs.fuse.fusefs_fbufs_wait Ta integer Ta no
+.It vfs.fuse.fusefs_pool_pages Ta integer Ta no
 .El
 .Pp
 The
@@ -449,6 +453,8 @@ definitions for second level ddb identif
 definitions for second level vfs identifiers
 .It Aq Pa nfs/nfs.h
 definitions for third level NFS identifiers
+.It Aq Pa miscfs/fuse/fusefs.h
+definitions for third level fusefs identifiers
 .It Aq Pa ufs/ffs/ffs_extern.h
 definitions for third level FFS identifiers
 .It Aq Pa machine/cpu.h



Re: sysctl fix

2013-06-06 Thread Sylvestre Gallon
And here the third one that removes all warns for :

WARNINGS=yes make

Cheers,

Index: sysctl.c
===
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.189
diff -u -p -u -p -r1.189 sysctl.c
--- sysctl.c16 Apr 2013 22:06:48 -  1.189
+++ sysctl.c6 Jun 2013 12:07:38 -
@@ -268,7 +268,8 @@ void
 listall(char *prefix, struct list *lp)
 {
char *cp, name[BUFSIZ];
-   int lvl2, len;
+   size_t len;
+   int lvl2;
 
if (lp-list == NULL)
return;
@@ -861,7 +862,7 @@ parse(char *string, int flags)
}
if (special  RNDSTATS) {
struct rndstats *rndstats = (struct rndstats *)buf;
-   int i;
+   size_t i;
 
if (!nflag)
(void)printf(%s%s, string, equ);
@@ -1025,7 +1026,7 @@ parse_ports(char *portspec, int *port, i
 
 void
 parse_baddynamic(int mib[], size_t len, char *string, void **newvalp,
-size_t *newsizep, int flags, int nflag)
+size_t *newsizep, int flags, int nf)
 {
static u_int32_t newbaddynamic[DP_MAPSIZE];
int port, high_port, baddynamic_loaded = 0, full_list_set = 0;
@@ -1043,7 +1044,7 @@ parse_baddynamic(int mib[], size_t len, 
size, 0, 0) == -1) {
if (flags == 0)
return;
-   if (!nflag)
+   if (!nf)
printf(%s: , string);
puts(kernel does contain bad dynamic 
port tables);
@@ -1280,13 +1281,13 @@ sysctl_bios(char *string, char **bufpp, 
mib[2] = indx;
if (indx == BIOS_DISKINFO) {
if (*bufpp == NULL) {
-   char name[BUFSIZ];
+   char str[BUFSIZ];
 
/* scan all the bios devices */
for (indx = 0; indx  256; indx++) {
-   snprintf(name, sizeof(name), %s.%u,
+   snprintf(str, sizeof(str), %s.%u,
string, indx);
-   parse(name, 1);
+   parse(str, 1);
}
return (-1);
}
@@ -1782,10 +1783,10 @@ sysctl_forkstat(char *string, char **buf
 int
 sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   int indx, stor, i;
+   int indx, stor;
char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
struct list lp;
-   size_t size;
+   size_t size, i;
 
if (*bufpp == NULL) {
listall(string, kernmalloclist);
@@ -2282,7 +2283,7 @@ sysctl_tc(char *string, char **bufpp, in
 int
 sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
 {
-   char *devname, *typename;
+   char *name, *typename;
int dev, numt, i;
enum sensor_type type;
struct sensordev snsrdev;
@@ -2312,7 +2313,7 @@ sysctl_sensors(char *string, char **bufp
 * provided below hw.sensors tree.
 * The first branch of hw.sensors tree is the device name.
 */
-   if ((devname = strsep(bufpp, .)) == NULL) {
+   if ((name = strsep(bufpp, .)) == NULL) {
warnx(%s: incomplete specification, string);
return (-1);
}
@@ -2325,11 +2326,11 @@ sysctl_sensors(char *string, char **bufp
if (errno == ENOENT)
break;
}
-   if (strcmp(devname, snsrdev.xname) == 0)
+   if (strcmp(name, snsrdev.xname) == 0)
break;
}
-   if (strcmp(devname, snsrdev.xname) != 0) {
-   warnx(%s: sensor device not found: %s, string, devname);
+   if (strcmp(name, snsrdev.xname) != 0) {
+   warnx(%s: sensor device not found: %s, string, name);
return (-1);
}
if (*bufpp == NULL) {
@@ -2586,6 +2587,7 @@ struct emulname {
 } *emul_names;
 intemul_num, nemuls;
 intemul_init(void);
+intemulcmp(const void *, const void *);
 
 int
 sysctl_emul(char *string, char *newval, int flags)



Re: Fuse (and sshfs) support for OpenBSD

2013-06-03 Thread Sylvestre Gallon
Here is the last patch. It does not differ from last time.

You only need to install sysutils/sshfs and if you have done all the last
tasks well. it will works like that : 

root # sshfs user@domainname:/path/to/file /mnt/

Cheers,

Index: sysutils/Makefile
===
RCS file: /cvs/ports/sysutils/Makefile,v
retrieving revision 1.290
diff -u -p -u -p -r1.290 Makefile
--- sysutils/Makefile   22 Apr 2013 06:48:58 -  1.290
+++ sysutils/Makefile   29 Apr 2013 13:50:36 -
@@ -188,6 +188,7 @@
  SUBDIR += snapdl
  SUBDIR += socket
  SUBDIR += socklog
+ SUBDIR += sshfs-fuse
  SUBDIR += stan
  SUBDIR += stow
  SUBDIR += stress
Index: sysutils/sshfs-fuse/Makefile
===
RCS file: sysutils/sshfs-fuse/Makefile
diff -N sysutils/sshfs-fuse/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/sshfs-fuse/Makefile29 Apr 2013 13:50:37 -
@@ -0,0 +1,24 @@
+# $OpenBSD: Makefile,v 1.33 2013/01/09 00:02:15 brad Exp $
+
+COMMENT=   Mount remote directories over ssh
+
+VERSION=   2.4
+DISTNAME=  sshfs-fuse-${VERSION}
+CATEGORIES=sysutils
+
+HOMEPAGE=  http://sshfs.sourceforge.net/
+MASTER_SITES=  
http://sourceforge.net/projects/fuse/files/sshfs-fuse/${VERSION}/
+
+MAINTAINER=Gallon Sylvestre ccna@gmail.com
+
+# LGPL
+PERMIT_PACKAGE_CDROM=  Yes
+PERMIT_PACKAGE_FTP=Yes
+PERMIT_DISTFILES_FTP=  Yes
+
+CONFIGURE_STYLE=gnu
+CONFIGURE_ARGS+= ${CONFIGURE_SHARED}
+WANTLIB=   c pthread glib-2.0
+LIB_DEPENDS+=  devel/glib2
+
+.include bsd.port.mk
Index: sysutils/sshfs-fuse/distinfo
===
RCS file: sysutils/sshfs-fuse/distinfo
diff -N sysutils/sshfs-fuse/distinfo
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/sshfs-fuse/distinfo29 Apr 2013 13:50:37 -
@@ -0,0 +1,2 @@
+SHA256 (sshfs-fuse-2.4.tar.gz) = PJO6hSJWgJPJT/nFo3Y5KTgN0ik2XZBXaf+CR113TdE=
+SIZE (sshfs-fuse-2.4.tar.gz) = 132930
Index: sysutils/sshfs-fuse/patches/patch-sshfs_c
===
RCS file: sysutils/sshfs-fuse/patches/patch-sshfs_c
diff -N sysutils/sshfs-fuse/patches/patch-sshfs_c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/sshfs-fuse/patches/patch-sshfs_c   29 Apr 2013 13:50:37 -
@@ -0,0 +1,27 @@
+--- sshfs.c.orig   Thu Mar  8 10:34:39 2012
 sshfs.cFri Mar 29 10:37:09 2013
+@@ -11,7 +11,6 @@
+ 
+ #include fuse.h
+ #include fuse_opt.h
+-#include fuse_lowlevel.h
+ #include assert.h
+ #include stdio.h
+ #include stdlib.h
+@@ -32,6 +31,7 @@
+ #include sys/utsname.h
+ #include sys/mman.h
+ #include sys/poll.h
++#include sys/mount.h
+ #include netinet/in.h
+ #include netinet/tcp.h
+ #include glib.h
+@@ -1543,7 +1543,7 @@ static int sftp_error_to_errno(uint32_t error)
+   case SSH_FX_NO_SUCH_FILE:  return ENOENT;
+   case SSH_FX_PERMISSION_DENIED: return EACCES;
+   case SSH_FX_FAILURE:   return EPERM;
+-  case SSH_FX_BAD_MESSAGE:   return EBADMSG;
++  case SSH_FX_BAD_MESSAGE:   return ENOMSG;
+   case SSH_FX_NO_CONNECTION: return ENOTCONN;
+   case SSH_FX_CONNECTION_LOST:   return ECONNABORTED;
+   case SSH_FX_OP_UNSUPPORTED:return EOPNOTSUPP;
Index: sysutils/sshfs-fuse/pkg/DESCR
===
RCS file: sysutils/sshfs-fuse/pkg/DESCR
diff -N sysutils/sshfs-fuse/pkg/DESCR
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/sshfs-fuse/pkg/DESCR   29 Apr 2013 13:50:37 -
@@ -0,0 +1 @@
+SSHFS allows you to mount a remote directory over a normal ssh connection.
Index: sysutils/sshfs-fuse/pkg/PLIST
===
RCS file: sysutils/sshfs-fuse/pkg/PLIST
diff -N sysutils/sshfs-fuse/pkg/PLIST
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/sshfs-fuse/pkg/PLIST   29 Apr 2013 13:50:37 -
@@ -0,0 +1,3 @@
+@comment $OpenBSD$
+@bin bin/sshfs
+@man man/man1/sshfs.1



Re: Fuse (and sshfs) support for OpenBSD

2013-04-19 Thread Sylvestre Gallon
On Fri, Apr 19, 2013 at 10:59 PM, Gregor Best g...@ring0.de wrote:
 Hi,

 [...]
 I will spend the next days working on the NetBSD librefuse, I will try
 to get it working with my kernel code and will come back here when I
 have something that works.
 [...]

 Are there any news on this? If you need a hand testing stuff and
 tracking down bugs, I'd be very happy to help.

 --
 Gregor Best

I am still working on it with the good advices of some devs (mpi@,
gilles@, todd@, armani@).

I Hope to have something re-submitable on tech@ in 1 or 2 weeks.

Cheers,
--
Sylvestre Gallon



Re: Fuse (and sshfs) support for OpenBSD

2013-03-07 Thread Sylvestre Gallon
On Thu, Mar 7, 2013 at 3:03 PM, Bob Beck b...@obtuse.com wrote:

 

 Which is why I keep pointing people at puffs and librefuse in netbsd



Hi,

Using puffs will induce a rewrite of all the kernel code, because the
internals are completely different (and I think a little bit more
complex, but this is a personal opinion...).

For a libfuse support in basesystem we will need to do a librefuse
like library. In this case we could perhaps keep the librefuse
frontend and only rewrite the backend.

Which solution do you think is best ? In any case and if you need me,
I will be provide all the help I can :)

Cheers,

--
Sylvestre Gallon



Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
Hi tech@

I send you this mail because a few months ago I tried to dabble with fuse
filesystem and OpenBSD. After some time working on this subject I have
succeeded to create something that works. It is not even near to be perfect
but with some changes and adaptions I think it could do the job.

In order to use these patches you will need to follow this procedure:

* apply the ports patch :
root # cd /usr/ports
root # ftp http://www.pmbsd.org/patch-fuse-ports
root # patch -p0  patch-fuse-ports

* apply the src patch
root # cd /usr/src
root # ftp http://www.pmbsd.org/patch-fuse-src
root # patch -p0  patch-fuse-src

* upgrade your system mount.h
root # cp /usr/src/sys/sys/mount.h /usr/include/sys/mount.h

* compile all mount and umount binaries
root # cd /usr/src/sbin/mount  make  make install
root # cd /usr/src/sbin/mount_ffs  make  make install
root # cd /usr/src/sbin/mount_fusefs  make  make install (there are
warning for a missing manpage)
  ...
root # cd /usr/src/sbin/umount  make  make install

* build a new kernel
root # cd /usr/src/sys/arch/i386/conf
root # config GENERIC
root # cd ../compile/GENERIC
root # make  make install

* update MAKEDEV script and launch it to create the fuse device
root # cd /dev
root # ftp http://www.pmbsd.org/patch-fuse-MAKEDEV
root # patch MAKEDEV  patch-fuse-MAKEDEV
root # ./MAKEDEV
root # ./MAKEDEV fuse

* install devel/fuse and sysutils/sshfs-fuse packages
   root # cd /usr/ports/devel/fuse  make  make install
   root # cd /usr/ports/sysutils/sshfs-fuse  make  make install

* reboot and try sshfs
   root # reboot
   root # sshfs s...@pmbsd.org:/home/syl/code /mnt
   root # ls /mnt


As I said before, this is not perfect... There are some outstanding
features to implement and bugs or architectural mistakes to solve...

There is some work to do to implement these missing vnops and vfs features :

  * vptof
  * fhtovp
  * checkexp
  * sysctl
  * strategy
  * fsync
  * symlink
  * rename vnop
  * you could only mount one filesystem at once.

I think some security improvement could be done on these patches like :
- fix some panics and tsleep hole that could produce DoS...
- allow the use of fuse with a securelevel equal to -1...
- other security stuff that I'm surely missing :)

I will not explain all the fuse protocol in this mail but if you want
information on how it works I will answer your questions in a private mail.

If you have any questions about these patches or want me to change or
rework something in this code I will be happy to do it.

Thanks for your time,

Cheers,

-- 
Sylvestre Gallon


Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
On Tue, Mar 5, 2013 at 2:44 PM, Bob Beck b...@openbsd.org wrote:

 Sylvestre, one of the problems with fuse itself is that it's GPL
 licensed, and not appropriate
 for inclusion in base. If you've got interets and talent in this area,
 you might want to consider
 having a peek at puffs (and refuse) from netbsd which has a workable
 license and could
 be included in base.   I would definitely help if you're interested...

 -Bob


Bob,

I am not quite sure but I think that only libfuse and sshfs are GPL
licenced. The patches for those two items are only present in ports.

All the code present in src is ISC licenced. The kernel communicate with
libfuse througth a device (ie /dev/fuse) and only share a header with the
libfuse (fuse_kernel.h) which is BSD licenced. FreeBSD used the same way to
implement it. (I do not know if it is a good example)

Anyway, It could be fun to have a peek at puffs/refuse and have your help :)

Cheers,

-- 
Sylvestre Gallon


Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
On Tue, Mar 5, 2013 at 4:29 PM, Sylvestre Gallon ccna@gmail.com wrote:

 Martin,

 You will find inline the kernel patch


And here the userland :

Index: Makefile
===
RCS file: /cvs/src/sbin/Makefile,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 Makefile
--- Makefile23 Aug 2012 06:37:27 -1.97
+++ Makefile5 Mar 2013 15:21:12 -
@@ -5,7 +5,7 @@ SUBDIR=atactl badsect bioctl clri dhcli
 fsck_msdos fsdb fsirand growfs ifconfig iked init iopctl ipsecctl  \
 isakmpd kbd ldattach lmccontrol mknod modload modunload mount \
 mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
-mount_nfs mount_ntfs mount_procfs mount_udf \
+mount_nfs mount_ntfs mount_procfs mount_fusefs mount_udf \
 mount_vnd mountd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
 nfsd nologin pdisk pfctl pflogd ping ping6 quotacheck \
 reboot restore route rtsol savecore scan_ffs \
Index: mount_fusefs/Makefile
===
RCS file: mount_fusefs/Makefile
diff -N mount_fusefs/Makefile
--- /dev/null1 Jan 1970 00:00:00 -
+++ mount_fusefs/Makefile5 Mar 2013 15:21:18 -
@@ -0,0 +1,10 @@
+#$OpenBSD: src/sbin/mount_procfs/Makefile,v 1.7 2004/06/22
21:12:00 otto Exp $
+
+PROG=mount_fusefs
+SRCS=mount_fusefs.c getmntopts.c
+
+MOUNT=${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH:${MOUNT}
+
+.include bsd.prog.mk
Index: mount_fusefs/mount_fusefs.c
===
RCS file: mount_fusefs/mount_fusefs.c
diff -N mount_fusefs/mount_fusefs.c
--- /dev/null1 Jan 1970 00:00:00 -
+++ mount_fusefs/mount_fusefs.c5 Mar 2013 15:21:18 -
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012 Sylvestre Gallon ccna@gmail.com
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include sys/param.h
+#include sys/mount.h
+
+#include err.h
+#include errno.h
+#include unistd.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include mntopts.h
+
+const struct mntopt mopts[] = {
+MOPT_STDOPTS,
+{ subtype,0, MFLAG_SET | MFLAG_STRVAL | MFLAG_OPT },
+{ fsname,0, MFLAG_SET | MFLAG_STRVAL | MFLAG_OPT },
+{ NULL }
+};
+
+voidusage(void);
+
+int
+main(int argc, char *argv[])
+{
+int ch, mntflags, altflags;
+struct fusefs_args args;
+char path[MAXPATHLEN];
+
+mntflags = altflags = 0;
+while ((ch = getopt(argc, argv, o:)) != -1)
+switch (ch) {
+case 'o':
+altflags |= getmntopts(optarg, mopts, mntflags);
+break;
+case '?':
+default:
+usage();
+}
+argc -= optind;
+argv += optind;
+
+if (argc != 2)
+usage();
+
+args.flags = altflags;
+args.fd = atoi(argv[0]);
+
+if (realpath(argv[1], path) == NULL)
+err(1, realpath %s, argv[1]);
+
+if (mount(MOUNT_FUSEFS, path, mntflags, args)) {
+if (errno == EOPNOTSUPP)
+errx(1, %s: Filesystem not supported by kernel,
+argv[1]);
+else
+err(1, %s, argv[1]);
+}
+exit(0);
+}
+
+void
+usage(void)
+{
+(void)fprintf(stderr,
+usage: mount_procfs [-o options] fd mount_point\n);
+exit(1);
+}



Compilation issue for kernel without USB.

2010-03-11 Thread Sylvestre Gallon
Hi tech@,

Using the following config file openbsd kernel does not compile :

http://pmbsd.org/~syl/OpenBSD/CONFIGWITHOUTUSB

I have fixed the problem with this little patch :

http://pmbsd.org/~syl/OpenBSD/usb-compil-diff

The problem is that btkbd driver uses the keymap of ukbd.

I don't know if you want to push the patch in the three (people
who compile kernel without USB support are rare and probably
drunk...) but I send you this patch just in case,  who knows :)

Cheers,

-- 
Sylvestre Gallon



MOKO

2009-07-14 Thread Sylvestre Gallon
Hi tech@,

Moko does not seem to compile on current.

I've tried to fix some compilation issues to compile a
working  kernel. The diff is in attach :)

About the LCD part I think that someone has forgotten
to commit a file, so I have filled this file with a dummy
one in my diff.

Cheers,

-- 
Sylvestre Gallon (http://devsyl.blogspot.com)
Fifth Grade Student @ Epitech  Researcher @ LSE
RD @ Rathaxes (http://www.rathaxes.org)



Re: MOKO

2009-07-14 Thread Sylvestre Gallon
On Tue, Jul 14, 2009 at 1:41 PM, Sylvestre Gallonccna@gmail.com wrote:
 Hi tech@,

 Moko does not seem to compile on current.

 I've tried to fix some compilation issues to compile a
 working  kernel. The diff is in attach :)

 About the LCD part I think that someone has forgotten
 to commit a file, so I have filled this file with a dummy
 one in my diff.

 Cheers,


matthieu@ just notify me that attachments are not
supported by tech .

I will also send this diff to drahn@ following matthieu@
advices.

Sorry for the spam...

Cheers,

diff :

Index: arch/arm/arm/pmap.c
===
RCS file: /cvs/src/sys/arch/arm/arm/pmap.c,v
retrieving revision 1.23
diff -N -u -p arch/arm/arm/pmap.c
--- arch/arm/arm/pmap.c 24 May 2009 04:56:19 -  1.23
+++ arch/arm/arm/pmap.c 14 Jul 2009 11:19:53 -
@@ -4692,7 +4692,7 @@ pmap_pte_init_generic(void)
pte_l1_c_proto = L1_C_PROTO_generic;
pte_l2_s_proto = L2_S_PROTO_generic;

-   pmap_copy_page_func = pmap_copy_page_v7;
+   pmap_copy_page_func = pmap_copy_page_generic;
pmap_zero_page_func = pmap_zero_page_generic;
 }

Index: arch/arm/arm/softintr.c
===
RCS file: /cvs/src/sys/arch/arm/arm/softintr.c,v
retrieving revision 1.6
diff -N -u -p arch/arm/arm/softintr.c
--- arch/arm/arm/softintr.c 19 Apr 2009 18:54:06 -  1.6
+++ arch/arm/arm/softintr.c 14 Jul 2009 11:19:53 -
@@ -133,9 +133,13 @@ softintr_establish(int ipl, void (*func)(void *), void
si = SI_SOFTNET;
break;

-   case IPL_TTY:
+/* case IPL_TTY:   */
case IPL_SOFTTTY:
si = SI_SOFTTTY;
+   break;
+
+   case IPL_SOFTSERIAL:
+   si = SI_SOFTSERIAL;
break;

default:
Index: arch/arm/include/softintr.h
===
RCS file: /cvs/src/sys/arch/arm/include/softintr.h,v
retrieving revision 1.4
diff -N -u -p arch/arm/include/softintr.h
--- arch/arm/include/softintr.h 19 Apr 2009 18:54:06 -  1.4
+++ arch/arm/include/softintr.h 14 Jul 2009 11:19:53 -
@@ -54,8 +54,9 @@
 #defineSI_SOFTCLOCK1   /* for IPL_SOFTCLOCK */
 #defineSI_SOFTNET  2   /* for IPL_SOFTNET */
 #defineSI_SOFTTTY  3   /* for IPL_SOFTTTY */
+#define SI_SOFTSERIAL  4   /* for IPL_SOFSERIAL */

-#defineSI_NQUEUES  4
+#defineSI_NQUEUES  5

 struct soft_intrhand {
TAILQ_ENTRY(soft_intrhand) sih_list;
? arch/arm/s3c2xx0/.files.s3c2410.swp
Index: arch/arm/s3c2xx0/s3c2xx0_intr.c
===
RCS file: /cvs/src/sys/arch/arm/s3c2xx0/s3c2xx0_intr.c,v
retrieving revision 1.2
diff -N -u -p arch/arm/s3c2xx0/s3c2xx0_intr.c
--- arch/arm/s3c2xx0/s3c2xx0_intr.c 8 Dec 2008 20:50:20 -   1.2
+++ arch/arm/s3c2xx0/s3c2xx0_intr.c 14 Jul 2009 11:19:53 -
@@ -85,6 +85,7 @@ __KERNEL_RCSID(0, $NetBSD: s3c2xx0_intr.c,v 1.13 2008
 #include machine/bus.h
 #include machine/intr.h
 #include arm/cpufunc.h
+#include arm/softintr.h

 #include arm/s3c2xx0/s3c2xx0reg.h
 #include arm/s3c2xx0/s3c2xx0var.h
? arch/moko/conf/.RAMDISK.swp
? arch/moko/conf/.files.moko.swp
Index: arch/moko/conf/files.moko
===
RCS file: /cvs/src/sys/arch/moko/conf/files.moko,v
retrieving revision 1.2
diff -N -u -p arch/moko/conf/files.moko
--- arch/moko/conf/files.moko   2 Jan 2009 06:38:24 -   1.2
+++ arch/moko/conf/files.moko   14 Jul 2009 11:19:54 -
@@ -24,8 +24,6 @@ include ../../../dev/atapiscsi/files.atapiscsi
 include arch/arm/s3c2xx0/files.s3c2410


-
-
 #
 # Machine-independent ATA drivers
 #
Index: arch/moko/dev/moko_lcd.c
===
RCS file: arch/moko/dev/moko_lcd.c
diff -N -u -p arch/moko/dev/moko_lcd.c
--- /dev/null   14 Jul 2009 11:20:00 -
+++ arch/moko/dev/moko_lcd.c14 Jul 2009 11:19:54 -
@@ -0,0 +1,39 @@
+#include sys/param.h
+#include sys/systm.h
+#include sys/errno.h
+#include sys/ioctl.h
+#include sys/device.h
+#include sys/proc.h
+#include sys/malloc.h
+
+#include machine/cpu.h
+#include machine/bus.h
+#include machine/intr.h
+
+struct lcd_softc {
+   struct device sc_dev;
+};
+
+static int lcd_match(struct device *, void *, void *);
+static voidlcd_attach(struct device *, struct device *, void *);
+
+struct cfattach lcd_ssio_ca = {
+   sizeof(struct lcd_softc), lcd_match, lcd_attach
+};
+
+struct cfdriver lcd_cd = {
+   NULL, lcd, DV_DULL
+};
+
+static int
+lcd_match(struct device *parent, void *match, void *aux)
+{
+   return 0;
+}
+
+static void
+lcd_attach(struct device *parent, struct device *self, void *aux)
+{
+   return ;
+}
+
Index: arch/moko/include/intr.h

Re: MOKO

2009-07-14 Thread Sylvestre Gallon
On Tue, Jul 14, 2009 at 4:13 PM, Dale Rahndr...@dalerahn.com wrote:
 On Tue, Jul 14, 2009 at 01:41:31PM +0200, Sylvestre Gallon wrote:
 Hi tech@,

 Moko does not seem to compile on current.

 I've tried to fix some compilation issues to compile a
 working  kernel. The diff is in attach :)

 About the LCD part I think that someone has forgotten
 to commit a file, so I have filled this file with a dummy
 one in my diff.


 Fixes, and the missing file are committed now, however I cannot test
 at the moment (on vacation) so testing would be appreciated.

 Dale Rahn   dr...@dalerahn.com


Hi,

The compile works fine now, but the kernel seems to hangs.
I have tried with cvs tag OPENBSD_4_5 but the kernel hangs
too (and moko_lcd.c is missing too).

I will try to setup an openocd tomorrow to have more
information about why the system hangs and repost in this
thread if I have any information.

Cheers,

--
Sylvestre Gallon (http://devsyl.blogspot.com)
Fifth Grade Student @ Epitech  Researcher @ LSE
RD @ Rathaxes (http://www.rathaxes.org)