Date: Fri, 7 Nov 2014 06:16:11 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r274221 - in user/dchagin/lemul: . bin/df rescue/rescue share/mk sys/cam/ctl sys/dev/ixl sys/dev/virtio/console sys/modules/ixlv tools/build usr.bin/wc Message-ID: <201411070616.sA76GBAX031650@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Fri Nov 7 06:16:10 2014 New Revision: 274221 URL: https://svnweb.freebsd.org/changeset/base/274221 Log: MFH. Added: user/dchagin/lemul/sys/dev/ixl/ixlv_vc_mgr.h - copied unchanged from r274220, head/sys/dev/ixl/ixlv_vc_mgr.h user/dchagin/lemul/tools/build/check-links.sh - copied unchanged from r274220, head/tools/build/check-links.sh Modified: user/dchagin/lemul/Makefile.inc1 user/dchagin/lemul/bin/df/Makefile user/dchagin/lemul/bin/df/df.1 user/dchagin/lemul/bin/df/df.c user/dchagin/lemul/rescue/rescue/Makefile user/dchagin/lemul/share/mk/bsd.lib.mk user/dchagin/lemul/share/mk/bsd.own.mk user/dchagin/lemul/share/mk/bsd.prog.mk user/dchagin/lemul/sys/cam/ctl/ctl.c user/dchagin/lemul/sys/cam/ctl/ctl_private.h user/dchagin/lemul/sys/dev/ixl/i40e_osdep.c user/dchagin/lemul/sys/dev/ixl/i40e_osdep.h user/dchagin/lemul/sys/dev/ixl/if_ixl.c user/dchagin/lemul/sys/dev/ixl/if_ixlv.c user/dchagin/lemul/sys/dev/ixl/ixl.h user/dchagin/lemul/sys/dev/ixl/ixl_txrx.c user/dchagin/lemul/sys/dev/ixl/ixlv.h user/dchagin/lemul/sys/dev/ixl/ixlvc.c user/dchagin/lemul/sys/dev/virtio/console/virtio_console.c user/dchagin/lemul/sys/modules/ixlv/Makefile user/dchagin/lemul/usr.bin/wc/wc.c Directory Properties: user/dchagin/lemul/ (props changed) user/dchagin/lemul/share/ (props changed) user/dchagin/lemul/sys/ (props changed) Modified: user/dchagin/lemul/Makefile.inc1 ============================================================================== --- user/dchagin/lemul/Makefile.inc1 Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/Makefile.inc1 Fri Nov 7 06:16:10 2014 (r274221) @@ -1537,6 +1537,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1 ${_kerberos5_lib_libwind} \ lib/libbz2 ${_libcom_err} lib/libcrypt \ lib/libelf lib/libexpat \ + lib/libfigpar \ ${_lib_libgssapi} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \ ${_lib_libcapsicum} \ @@ -1551,7 +1552,8 @@ _prebuild_libs= ${_kerberos5_lib_libasn1 ${_cddl_lib_libctf} \ lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \ ${_secure_lib_libcrypto} ${_lib_libldns} \ - ${_secure_lib_libssh} ${_secure_lib_libssl} + ${_secure_lib_libssh} ${_secure_lib_libssl} \ + gnu/lib/libdialog .if ${MK_GNUCXX} != "no" _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++ gnu/lib/libstdc++__L: lib/msun__L @@ -1669,6 +1671,8 @@ _lib_libypclnt= lib/libypclnt lib/libradius__L: lib/libmd__L .endif +gnu/lib/libdialog__L: lib/ncurses/ncursesw__L + .for _lib in ${_prereq_libs} ${_lib}__PL: .PHONY .MAKE .if exists(${.CURDIR}/${_lib}) Modified: user/dchagin/lemul/bin/df/Makefile ============================================================================== --- user/dchagin/lemul/bin/df/Makefile Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/bin/df/Makefile Fri Nov 7 06:16:10 2014 (r274221) @@ -9,7 +9,7 @@ SRCS= df.c vfslist.c CFLAGS+= -I${MOUNT} -DPADD= ${LIBUTIL} -LDADD= -lutil +DPADD= ${LIBUTIL} ${LIBXO} +LDADD= -lutil -lxo .include <bsd.prog.mk> Modified: user/dchagin/lemul/bin/df/df.1 ============================================================================== --- user/dchagin/lemul/bin/df/df.1 Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/bin/df/df.1 Fri Nov 7 06:16:10 2014 (r274221) @@ -29,7 +29,7 @@ .\" @(#)df.1 8.3 (Berkeley) 5/8/95 .\" $FreeBSD$ .\" -.Dd January 16, 2014 +.Dd November 6, 2014 .Dt DF 1 .Os .Sh NAME @@ -37,6 +37,7 @@ .Nd display free disk space .Sh SYNOPSIS .Nm +.Op Fl -libxo .Op Fl b | g | H | h | k | m | P .Op Fl acilnT .Op Fl \&, @@ -193,7 +194,9 @@ If the value is outside, it will be set .Xr statfs 2 , .Xr getbsize 3 , .Xr getmntinfo 3 , +.Xr libxo 3 , .Xr localeconv 3 , +.Xr xo_parse_args 3 , .Xr fstab 5 , .Xr mount 8 , .Xr pstat 8 , Modified: user/dchagin/lemul/bin/df/df.c ============================================================================== --- user/dchagin/lemul/bin/df/df.c Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/bin/df/df.c Fri Nov 7 06:16:10 2014 (r274221) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <sysexits.h> #include <unistd.h> +#include <libxo/xo.h> #include "extern.h" @@ -82,7 +83,7 @@ static char *getmntpt(const char *); static int int64width(int64_t); static char *makenetvfslist(void); static void prthuman(const struct statfs *, int64_t); -static void prthumanval(int64_t); +static void prthumanval(const char *, int64_t); static intmax_t fsbtoblk(int64_t, uint64_t, u_long); static void prtstat(struct statfs *, struct maxwidths *); static size_t regetmntinfo(struct statfs **, long, const char **); @@ -119,6 +120,11 @@ main(int argc, char *argv[]) totalbuf.f_bsize = DEV_BSIZE; strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); vfslist = NULL; + + argc = xo_parse_args(argc, argv); + if (argc < 0) + exit(1); + while ((ch = getopt(argc, argv, "abcgHhiklmnPt:T,")) != -1) switch (ch) { case 'a': @@ -161,7 +167,7 @@ main(int argc, char *argv[]) break; case 'l': if (vfslist != NULL) - errx(1, "-l and -t are mutually exclusive."); + xo_errx(1, "-l and -t are mutually exclusive."); vfslist = makevfslist(makenetvfslist()); lflag = 1; break; @@ -174,9 +180,9 @@ main(int argc, char *argv[]) break; case 't': if (lflag) - errx(1, "-l and -t are mutually exclusive."); + xo_errx(1, "-l and -t are mutually exclusive."); if (vfslist != NULL) - errx(1, "only one -t option may be specified"); + xo_errx(1, "only one -t option may be specified"); fstype = optarg; vfslist = makevfslist(optarg); break; @@ -202,16 +208,19 @@ main(int argc, char *argv[]) /* just the filesystems specified on the command line */ mntbuf = malloc(argc * sizeof(*mntbuf)); if (mntbuf == NULL) - err(1, "malloc()"); + xo_err(1, "malloc()"); mntsize = 0; /* continued in for loop below */ } + xo_open_container("storage-system-information"); + xo_open_list("filesystem"); + /* iterate through specified filesystems */ for (; *argv; argv++) { if (stat(*argv, &stbuf) < 0) { if ((mntpt = getmntpt(*argv)) == NULL) { - warn("%s", *argv); + xo_warn("%s", *argv); rv = 1; continue; } @@ -220,20 +229,20 @@ main(int argc, char *argv[]) mdev.fspec = *argv; mntpath = strdup("/tmp/df.XXXXXX"); if (mntpath == NULL) { - warn("strdup failed"); + xo_warn("strdup failed"); rv = 1; continue; } mntpt = mkdtemp(mntpath); if (mntpt == NULL) { - warn("mkdtemp(\"%s\") failed", mntpath); + xo_warn("mkdtemp(\"%s\") failed", mntpath); rv = 1; free(mntpath); continue; } if (mount(fstype, mntpt, MNT_RDONLY, &mdev) != 0) { - warn("%s", *argv); + xo_warn("%s", *argv); rv = 1; (void)rmdir(mntpt); free(mntpath); @@ -244,7 +253,7 @@ main(int argc, char *argv[]) if (cflag) addstat(&totalbuf, &statfsbuf); } else { - warn("%s", *argv); + xo_warn("%s", *argv); rv = 1; } (void)unmount(mntpt, 0); @@ -260,7 +269,7 @@ main(int argc, char *argv[]) * implement nflag here. */ if (statfs(mntpt, &statfsbuf) < 0) { - warn("%s", mntpt); + xo_warn("%s", mntpt); rv = 1; continue; } @@ -294,8 +303,14 @@ main(int argc, char *argv[]) for (i = 0; i < mntsize; i++) if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) prtstat(&mntbuf[i], &maxwidths); + + xo_close_list("filesystem"); + if (cflag) prtstat(&totalbuf, &maxwidths); + + xo_close_container("storage-system-information"); + xo_finish(); return (rv); } @@ -341,7 +356,7 @@ regetmntinfo(struct statfs **mntbufp, lo if (nflag || error < 0) if (i != j) { if (error < 0) - warnx("%s stats possibly stale", + xo_warnx("%s stats possibly stale", mntbuf[i].f_mntonname); mntbuf[j] = mntbuf[i]; } @@ -354,13 +369,13 @@ static void prthuman(const struct statfs *sfsp, int64_t used) { - prthumanval(sfsp->f_blocks * sfsp->f_bsize); - prthumanval(used * sfsp->f_bsize); - prthumanval(sfsp->f_bavail * sfsp->f_bsize); + prthumanval(" {:blocks/%6s}", sfsp->f_blocks * sfsp->f_bsize); + prthumanval(" {:used/%6s}", used * sfsp->f_bsize); + prthumanval(" {:available/%6s}", sfsp->f_bavail * sfsp->f_bsize); } static void -prthumanval(int64_t bytes) +prthumanval(const char *fmt, int64_t bytes) { char buf[6]; int flags; @@ -372,14 +387,15 @@ prthumanval(int64_t bytes) humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, flags); - (void)printf(" %6s", buf); + xo_attr("value", "%lld", (long long) bytes); + xo_emit(fmt, buf); } /* * Print an inode count in "human-readable" format. */ static void -prthumanvalinode(int64_t bytes) +prthumanvalinode(const char *fmt, int64_t bytes) { char buf[6]; int flags; @@ -389,7 +405,8 @@ prthumanvalinode(int64_t bytes) humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, flags); - (void)printf(" %5s", buf); + xo_attr("value", "%lld", (long long) bytes); + xo_emit(fmt, buf); } /* @@ -434,70 +451,77 @@ prtstat(struct statfs *sfsp, struct maxw mwp->used = imax(mwp->used, (int)strlen("Used")); mwp->avail = imax(mwp->avail, (int)strlen("Avail")); - (void)printf("%-*s", mwp->mntfrom, "Filesystem"); + xo_emit("{T:/%-*s}", mwp->mntfrom, "Filesystem"); if (Tflag) - (void)printf(" %-*s", mwp->fstype, "Type"); - (void)printf(" %*s %*s %*s Capacity", mwp->total, header, - mwp->used, "Used", mwp->avail, "Avail"); + xo_emit(" {T:/%-*s}", mwp->fstype, "Type"); + xo_emit(" {T:/%*s} {T:/%*s} {T:/%*s} Capacity", + mwp->total, header, + mwp->used, "Used", mwp->avail, "Avail"); if (iflag) { mwp->iused = imax(hflag ? 0 : mwp->iused, (int)strlen(" iused")); mwp->ifree = imax(hflag ? 0 : mwp->ifree, (int)strlen("ifree")); - (void)printf(" %*s %*s %%iused", + xo_emit(" {T:/%*s} {T:/%*s} {T:\%iused}", mwp->iused - 2, "iused", mwp->ifree, "ifree"); } - (void)printf(" Mounted on\n"); + xo_emit(" {T:Mounted on}\n"); } + + xo_open_instance("filesystem"); /* Check for 0 block size. Can this happen? */ if (sfsp->f_bsize == 0) { - warnx ("File system %s does not have a block size, assuming 512.", + xo_warnx ("File system %s does not have a block size, assuming 512.", sfsp->f_mntonname); sfsp->f_bsize = 512; } - (void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname); + xo_emit("{tk:name/%-*s}", mwp->mntfrom, sfsp->f_mntfromname); if (Tflag) - (void)printf(" %-*s", mwp->fstype, sfsp->f_fstypename); + xo_emit(" {:type/%-*s}", mwp->fstype, sfsp->f_fstypename); used = sfsp->f_blocks - sfsp->f_bfree; availblks = sfsp->f_bavail + used; if (hflag) { prthuman(sfsp, used); } else { if (thousands) - format = " %*j'd %*j'd %*j'd"; + format = " {t:total-blocks/%*j'd} {t:used-blocks/%*j'd} " + "{t:available-blocks/%*j'd}"; else - format = " %*jd %*jd %*jd"; - (void)printf(format, + format = " {t:total-blocks/%*jd} {t:used-blocks/%*jd} " + "{t:available-blocks/%*jd}"; + xo_emit(format, mwp->total, fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize), mwp->used, fsbtoblk(used, sfsp->f_bsize, blocksize), mwp->avail, fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize)); } - (void)printf(" %5.0f%%", + xo_emit(" {:used-percent/%5.0f}{U:%%}", availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0); if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; if (hflag) { - (void)printf(" "); - prthumanvalinode(used); - prthumanvalinode(sfsp->f_ffree); + xo_emit(" "); + prthumanvalinode(" {:inodes-used/%5s}", used); + prthumanvalinode(" {:inodes-free/%5s}", sfsp->f_ffree); } else { if (thousands) - format = " %*j'd %*j'd"; + format = " {:inodes-used/%*j'd} {:inodes-free/%*j'd}"; else - format = " %*jd %*jd"; - (void)printf(format, mwp->iused, (intmax_t)used, + format = " {:inodes-used/%*jd} {:inodes-free/%*jd}"; + xo_emit(format, mwp->iused, (intmax_t)used, mwp->ifree, (intmax_t)sfsp->f_ffree); } - (void)printf(" %4.0f%% ", inodes == 0 ? 100.0 : - (double)used / (double)inodes * 100.0); + xo_emit(" {:inodes-used-percent/%4.0f}{U:%%} ", + inodes == 0 ? 100.0 : + (double)used / (double)inodes * 100.0); } else - (void)printf(" "); + xo_emit(" "); if (strncmp(sfsp->f_mntfromname, "total", MNAMELEN) != 0) - (void)printf(" %s", sfsp->f_mntonname); - (void)printf("\n"); + xo_emit(" {:mounted-on}", sfsp->f_mntonname); + xo_emit("\n"); + xo_close_instance("filesystem"); } static void @@ -564,7 +588,7 @@ static void usage(void) { - (void)fprintf(stderr, + xo_error( "usage: df [-b | -g | -H | -h | -k | -m | -P] [-acilnT] [-t type] [-,]\n" " [file | filesystem ...]\n"); exit(EX_USAGE); @@ -579,24 +603,24 @@ makenetvfslist(void) int cnt, i, maxvfsconf; if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) { - warn("sysctl(vfs.conflist)"); + xo_warn("sysctl(vfs.conflist)"); return (NULL); } xvfsp = malloc(buflen); if (xvfsp == NULL) { - warnx("malloc failed"); + xo_warnx("malloc failed"); return (NULL); } keep_xvfsp = xvfsp; if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) { - warn("sysctl(vfs.conflist)"); + xo_warn("sysctl(vfs.conflist)"); free(keep_xvfsp); return (NULL); } maxvfsconf = buflen / sizeof(struct xvfsconf); if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { - warnx("malloc failed"); + xo_warnx("malloc failed"); free(keep_xvfsp); return (NULL); } @@ -605,7 +629,7 @@ makenetvfslist(void) if (xvfsp->vfc_flags & VFCF_NETWORK) { listptr[cnt++] = strdup(xvfsp->vfc_name); if (listptr[cnt-1] == NULL) { - warnx("malloc failed"); + xo_warnx("malloc failed"); free(listptr); free(keep_xvfsp); return (NULL); @@ -617,7 +641,7 @@ makenetvfslist(void) if (cnt == 0 || (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { if (cnt > 0) - warnx("malloc failed"); + xo_warnx("malloc failed"); free(listptr); free(keep_xvfsp); return (NULL); Modified: user/dchagin/lemul/rescue/rescue/Makefile ============================================================================== --- user/dchagin/lemul/rescue/rescue/Makefile Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/rescue/rescue/Makefile Fri Nov 7 06:16:10 2014 (r274221) @@ -52,7 +52,7 @@ CRUNCH_SRCDIRS+= bin CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ ed expr getfacl hostname kenv kill ln ls mkdir mv \ pkill ps pwd realpath rm rmdir setfacl sh stty sync test -CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -ll -ltermcapw -lutil +CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -ll -ltermcapw -lutil -lxo CRUNCH_BUILDTOOLS+= bin/sh # Additional options for specific programs Modified: user/dchagin/lemul/share/mk/bsd.lib.mk ============================================================================== --- user/dchagin/lemul/share/mk/bsd.lib.mk Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/share/mk/bsd.lib.mk Fri Nov 7 06:16:10 2014 (r274221) @@ -36,7 +36,7 @@ NO_WERROR= .if defined(DEBUG_FLAGS) CFLAGS+= ${DEBUG_FLAGS} -.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" +.if ${MK_CTF} != "no" CTFFLAGS+= -g .endif .else Modified: user/dchagin/lemul/share/mk/bsd.own.mk ============================================================================== --- user/dchagin/lemul/share/mk/bsd.own.mk Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/share/mk/bsd.own.mk Fri Nov 7 06:16:10 2014 (r274221) @@ -128,6 +128,7 @@ __<bsd.own.mk>__: .if ${MK_CTF} != "no" CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +DEBUG_FLAGS+= -g .elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300) CTFCONVERT_CMD= .else Modified: user/dchagin/lemul/share/mk/bsd.prog.mk ============================================================================== --- user/dchagin/lemul/share/mk/bsd.prog.mk Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/share/mk/bsd.prog.mk Fri Nov 7 06:16:10 2014 (r274221) @@ -20,7 +20,7 @@ NO_WERROR= CFLAGS+=${DEBUG_FLAGS} CXXFLAGS+=${DEBUG_FLAGS} -.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" +.if ${MK_CTF} != "no" CTFFLAGS+= -g .endif .endif Modified: user/dchagin/lemul/sys/cam/ctl/ctl.c ============================================================================== --- user/dchagin/lemul/sys/cam/ctl/ctl.c Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/sys/cam/ctl/ctl.c Fri Nov 7 06:16:10 2014 (r274221) @@ -4197,17 +4197,11 @@ ctl_init_page_index(struct ctl_lun *lun) * works out a fake geometry based on the capacity. */ memcpy(&lun->mode_pages.rigid_disk_page[ - CTL_PAGE_CURRENT], &rigid_disk_page_default, + CTL_PAGE_DEFAULT], &rigid_disk_page_default, sizeof(rigid_disk_page_default)); memcpy(&lun->mode_pages.rigid_disk_page[ CTL_PAGE_CHANGEABLE],&rigid_disk_page_changeable, sizeof(rigid_disk_page_changeable)); - memcpy(&lun->mode_pages.rigid_disk_page[ - CTL_PAGE_DEFAULT], &rigid_disk_page_default, - sizeof(rigid_disk_page_default)); - memcpy(&lun->mode_pages.rigid_disk_page[ - CTL_PAGE_SAVED], &rigid_disk_page_default, - sizeof(rigid_disk_page_default)); sectors_per_cylinder = CTL_DEFAULT_SECTORS_PER_TRACK * CTL_DEFAULT_HEADS; @@ -4244,16 +4238,21 @@ ctl_init_page_index(struct ctl_lun *lun) cylinders = 0xffffff; rigid_disk_page = &lun->mode_pages.rigid_disk_page[ - CTL_PAGE_CURRENT]; - scsi_ulto3b(cylinders, rigid_disk_page->cylinders); - - rigid_disk_page = &lun->mode_pages.rigid_disk_page[ CTL_PAGE_DEFAULT]; scsi_ulto3b(cylinders, rigid_disk_page->cylinders); - rigid_disk_page = &lun->mode_pages.rigid_disk_page[ - CTL_PAGE_SAVED]; - scsi_ulto3b(cylinders, rigid_disk_page->cylinders); + if ((value = ctl_get_opt(&lun->be_lun->options, + "rpm")) != NULL) { + scsi_ulto2b(strtol(value, NULL, 0), + rigid_disk_page->rotation_rate); + } + + memcpy(&lun->mode_pages.rigid_disk_page[CTL_PAGE_CURRENT], + &lun->mode_pages.rigid_disk_page[CTL_PAGE_DEFAULT], + sizeof(rigid_disk_page_default)); + memcpy(&lun->mode_pages.rigid_disk_page[CTL_PAGE_SAVED], + &lun->mode_pages.rigid_disk_page[CTL_PAGE_DEFAULT], + sizeof(rigid_disk_page_default)); page_index->page_data = (uint8_t *)lun->mode_pages.rigid_disk_page; @@ -10413,7 +10412,7 @@ ctl_inquiry_evpd_bdc(struct ctl_scsiio * (value = ctl_get_opt(&lun->be_lun->options, "rpm")) != NULL) i = strtol(value, NULL, 0); else - i = SVPD_NON_ROTATING; + i = CTL_DEFAULT_ROTATION_RATE; scsi_ulto2b(i, bdc_ptr->medium_rotation_rate); if (lun != NULL && (value = ctl_get_opt(&lun->be_lun->options, "formfactor")) != NULL) Modified: user/dchagin/lemul/sys/cam/ctl/ctl_private.h ============================================================================== --- user/dchagin/lemul/sys/cam/ctl/ctl_private.h Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/sys/cam/ctl/ctl_private.h Fri Nov 7 06:16:10 2014 (r274221) @@ -271,7 +271,7 @@ union ctl_softcs { #define CTL_DEFAULT_SECTORS_PER_TRACK 256 #define CTL_DEFAULT_HEADS 128 -#define CTL_DEFAULT_ROTATION_RATE 10000 +#define CTL_DEFAULT_ROTATION_RATE SVPD_NON_ROTATING struct ctl_page_index; Modified: user/dchagin/lemul/sys/dev/ixl/i40e_osdep.c ============================================================================== --- user/dchagin/lemul/sys/dev/ixl/i40e_osdep.c Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/sys/dev/ixl/i40e_osdep.c Fri Nov 7 06:16:10 2014 (r274221) @@ -107,6 +107,7 @@ i40e_allocate_dma_mem(struct i40e_hw *hw "error %u\n", err); goto fail_2; } + mem->nseg = 1; mem->size = size; bus_dmamap_sync(mem->tag, mem->map, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); Modified: user/dchagin/lemul/sys/dev/ixl/i40e_osdep.h ============================================================================== --- user/dchagin/lemul/sys/dev/ixl/i40e_osdep.h Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/sys/dev/ixl/i40e_osdep.h Fri Nov 7 06:16:10 2014 (r274221) @@ -147,8 +147,7 @@ void prefetch(void *x) #define prefetch(x) #endif -struct i40e_osdep -{ +struct i40e_osdep { bus_space_tag_t mem_bus_space_tag; bus_space_handle_t mem_bus_space_handle; bus_size_t mem_bus_space_size; Modified: user/dchagin/lemul/sys/dev/ixl/if_ixl.c ============================================================================== --- user/dchagin/lemul/sys/dev/ixl/if_ixl.c Fri Nov 7 06:11:54 2014 (r274220) +++ user/dchagin/lemul/sys/dev/ixl/if_ixl.c Fri Nov 7 06:16:10 2014 (r274221) @@ -40,7 +40,7 @@ /********************************************************************* * Driver version *********************************************************************/ -char ixl_driver_version[] = "1.2.2"; +char ixl_driver_version[] = "1.2.8"; /********************************************************************* * PCI Device ID Table @@ -109,6 +109,7 @@ static bool ixl_config_link(struct i40e_ static void ixl_config_rss(struct ixl_vsi *); static void ixl_set_queue_rx_itr(struct ixl_queue *); static void ixl_set_queue_tx_itr(struct ixl_queue *); +static int ixl_set_advertised_speeds(struct ixl_pf *, int); static void ixl_enable_rings(struct ixl_vsi *); static void ixl_disable_rings(struct ixl_vsi *); @@ -155,6 +156,7 @@ static void ixl_do_adminq(void *, int); static int ixl_set_flowcntl(SYSCTL_HANDLER_ARGS); static int ixl_set_advertise(SYSCTL_HANDLER_ARGS); static int ixl_current_speed(SYSCTL_HANDLER_ARGS); +static int ixl_sysctl_show_fw(SYSCTL_HANDLER_ARGS); /* Statistics */ static void ixl_add_hw_stats(struct ixl_pf *); @@ -176,7 +178,8 @@ static void ixl_stat_update32(struct i40 static int ixl_sysctl_link_status(SYSCTL_HANDLER_ARGS); static int ixl_sysctl_phy_abilities(SYSCTL_HANDLER_ARGS); static int ixl_sysctl_sw_filter_list(SYSCTL_HANDLER_ARGS); -static int ixl_sysctl_hw_res_info(SYSCTL_HANDLER_ARGS); +static int ixl_sysctl_hw_res_alloc(SYSCTL_HANDLER_ARGS); +static int ixl_sysctl_switch_config(SYSCTL_HANDLER_ARGS); static int ixl_sysctl_dump_txd(SYSCTL_HANDLER_ARGS); #endif @@ -276,6 +279,7 @@ int ixl_atr_rate = 20; TUNABLE_INT("hw.ixl.atr_rate", &ixl_atr_rate); #endif + static char *ixl_fc_string[6] = { "None", "Rx", @@ -398,6 +402,11 @@ ixl_attach(device_t dev) OID_AUTO, "current_speed", CTLTYPE_STRING | CTLFLAG_RD, pf, 0, ixl_current_speed, "A", "Current Port Speed"); + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "fw_version", CTLTYPE_STRING | CTLFLAG_RD, + pf, 0, ixl_sysctl_show_fw, "A", "Firmware version"); + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rx_itr", CTLFLAG_RW, @@ -436,8 +445,13 @@ ixl_attach(device_t dev) SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "hw_res_info", CTLTYPE_STRING | CTLFLAG_RD, - pf, 0, ixl_sysctl_hw_res_info, "A", "HW Resource Allocation"); + OID_AUTO, "hw_res_alloc", CTLTYPE_STRING | CTLFLAG_RD, + pf, 0, ixl_sysctl_hw_res_alloc, "A", "HW Resource Allocation"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "switch_config", CTLTYPE_STRING | CTLFLAG_RD, + pf, 0, ixl_sysctl_switch_config, "A", "HW Switch Configuration"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), @@ -445,7 +459,7 @@ ixl_attach(device_t dev) pf, 0, ixl_sysctl_dump_txd, "I", "Desc dump"); #endif - /* Save off the information about this board */ + /* Save off the PCI information */ hw->vendor_id = pci_get_vendor(dev); hw->device_id = pci_get_device(dev); hw->revision_id = pci_read_config(dev, PCIR_REVID, 1); @@ -593,6 +607,7 @@ ixl_attach(device_t dev) bcopy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN); i40e_get_port_mac_addr(hw, hw->mac.port_addr); + /* Set up VSI and queues */ if (ixl_setup_stations(pf) != 0) { device_printf(dev, "setup stations failed!\n"); error = ENOMEM; @@ -630,8 +645,11 @@ ixl_attach(device_t dev) "an unqualified module was detected\n"); /* Setup OS specific network interface */ - if (ixl_setup_interface(dev, vsi) != 0) + if (ixl_setup_interface(dev, vsi) != 0) { + device_printf(dev, "interface setup failed!\n"); + error = EIO; goto err_late; + } /* Get the bus configuration and set the shared code */ bus = ixl_get_bus_info(hw, dev); @@ -642,25 +660,32 @@ ixl_attach(device_t dev) ixl_update_stats_counters(pf); ixl_add_hw_stats(pf); + /* Reset port's advertised speeds */ + if (!i40e_is_40G_device(hw->device_id)) { + pf->advertised_speed = 0x7; + ixl_set_advertised_speeds(pf, 0x7); + } + /* Register for VLAN events */ vsi->vlan_attach = EVENTHANDLER_REGISTER(vlan_config, ixl_register_vlan, vsi, EVENTHANDLER_PRI_FIRST); vsi->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, ixl_unregister_vlan, vsi, EVENTHANDLER_PRI_FIRST); + INIT_DEBUGOUT("ixl_attach: end"); return (0); err_late: - ixl_free_vsi(vsi); + if (vsi->ifp != NULL) + if_free(vsi->ifp); err_mac_hmc: i40e_shutdown_lan_hmc(hw); err_get_cap: i40e_shutdown_adminq(hw); err_out: - if (vsi->ifp != NULL) - if_free(vsi->ifp); ixl_free_pci_resources(pf); + ixl_free_vsi(vsi); IXL_PF_LOCK_DESTROY(pf); return (error); } @@ -725,6 +750,7 @@ ixl_detach(device_t dev) ether_ifdetach(vsi->ifp); callout_drain(&pf->timer); + ixl_free_pci_resources(pf); bus_generic_detach(dev); if_free(vsi->ifp); @@ -2246,6 +2272,34 @@ early: return; } +static void +ixl_add_ifmedia(struct ixl_vsi *vsi, u32 phy_type) +{ + /* Display supported media types */ + if (phy_type & (1 << I40E_PHY_TYPE_100BASE_TX)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_100_TX, 0, NULL); + + if (phy_type & (1 << I40E_PHY_TYPE_1000BASE_T)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_1000_T, 0, NULL); + + if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_CR1_CU) || + phy_type & (1 << I40E_PHY_TYPE_10GBASE_SFPP_CU)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_TWINAX, 0, NULL); + if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_SR)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_SR, 0, NULL); + if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_LR)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_LR, 0, NULL); + if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_T)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_T, 0, NULL); + + if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) || + phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_CR4, 0, NULL); + if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_SR4)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_SR4, 0, NULL); + if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_LR4)) + ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_LR4, 0, NULL); +} /********************************************************************* * @@ -2276,7 +2330,7 @@ ixl_setup_interface(device_t dev, struct ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixl_ioctl; -#if __FreeBSD_version >= 1100000 +#if __FreeBSD_version >= 1100036 if_setgetcounterfn(ifp, ixl_get_counter); #endif @@ -2286,8 +2340,6 @@ ixl_setup_interface(device_t dev, struct ifp->if_snd.ifq_maxlen = que->num_desc - 2; - ether_ifattach(ifp, hw->mac.addr); - vsi->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN; @@ -2328,40 +2380,26 @@ ixl_setup_interface(device_t dev, struct ixl_media_status); aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, TRUE, &abilities_resp, NULL); - if (aq_error) { - printf("Error getting supported media types, AQ error %d\n", aq_error); - return (EPERM); - } - - /* Display supported media types */ - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_100BASE_TX)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_100_TX, 0, NULL); - - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_1000BASE_T)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_1000_T, 0, NULL); - - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_10GBASE_CR1_CU) || - abilities_resp.phy_type & (1 << I40E_PHY_TYPE_10GBASE_SFPP_CU)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_TWINAX, 0, NULL); - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_10GBASE_SR)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_SR, 0, NULL); - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_10GBASE_LR)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_LR, 0, NULL); - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_10GBASE_T)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_T, 0, NULL); - - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) || - abilities_resp.phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_CR4, 0, NULL); - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_40GBASE_SR4)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_SR4, 0, NULL); - if (abilities_resp.phy_type & (1 << I40E_PHY_TYPE_40GBASE_LR4)) - ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_LR4, 0, NULL); + if (aq_error == I40E_ERR_UNKNOWN_PHY) { + /* Need delay to detect fiber correctly */ + i40e_msec_delay(200); + aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, TRUE, &abilities_resp, NULL); + if (aq_error == I40E_ERR_UNKNOWN_PHY) + device_printf(dev, "Unknown PHY type detected!\n"); + else + ixl_add_ifmedia(vsi, abilities_resp.phy_type); + } else if (aq_error) { + device_printf(dev, "Error getting supported media types, err %d," + " AQ error %d\n", aq_error, hw->aq.asq_last_status); + } else + ixl_add_ifmedia(vsi, abilities_resp.phy_type); /* Use autoselect media by default */ ifmedia_add(&vsi->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&vsi->media, IFM_ETHER | IFM_AUTO); + ether_ifattach(ifp, hw->mac.addr); + return (0); } @@ -3728,10 +3766,6 @@ ixl_update_stats_counters(struct ixl_pf pf->stat_offsets_loaded, &osd->eth.rx_discards, &nsd->eth.rx_discards); - ixl_stat_update32(hw, I40E_GLPRT_TDPC(hw->port), - pf->stat_offsets_loaded, - &osd->eth.tx_discards, - &nsd->eth.tx_discards); ixl_stat_update48(hw, I40E_GLPRT_UPRCH(hw->port), I40E_GLPRT_UPRCL(hw->port), pf->stat_offsets_loaded, @@ -3915,8 +3949,8 @@ ixl_do_adminq(void *context, int pending u32 reg, loop = 0; u16 opcode, result; - event.msg_len = IXL_AQ_BUF_SZ; - event.msg_buf = malloc(event.msg_len, + event.buf_len = IXL_AQ_BUF_SZ; + event.msg_buf = malloc(event.buf_len, M_DEVBUF, M_NOWAIT | M_ZERO); if (!event.msg_buf) { printf("Unable to allocate adminq memory\n"); @@ -4300,6 +4334,52 @@ ixl_current_speed(SYSCTL_HANDLER_ARGS) return (error); } +static int +ixl_set_advertised_speeds(struct ixl_pf *pf, int speeds) +{ + struct i40e_hw *hw = &pf->hw; + device_t dev = pf->dev; + struct i40e_aq_get_phy_abilities_resp abilities; + struct i40e_aq_set_phy_config config; + enum i40e_status_code aq_error = 0; + + /* Get current capability information */ + aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, FALSE, &abilities, NULL); + if (aq_error) { + device_printf(dev, "%s: Error getting phy capabilities %d," + " aq error: %d\n", __func__, aq_error, + hw->aq.asq_last_status); + return (EAGAIN); + } + + /* Prepare new config */ + bzero(&config, sizeof(config)); + config.phy_type = abilities.phy_type; + config.abilities = abilities.abilities + | I40E_AQ_PHY_ENABLE_ATOMIC_LINK; + config.eee_capability = abilities.eee_capability; + config.eeer = abilities.eeer_val; + config.low_power_ctrl = abilities.d3_lpan; + /* Translate into aq cmd link_speed */ + if (speeds & 0x4) + config.link_speed |= I40E_LINK_SPEED_10GB; + if (speeds & 0x2) + config.link_speed |= I40E_LINK_SPEED_1GB; + if (speeds & 0x1) + config.link_speed |= I40E_LINK_SPEED_100MB; + + /* Do aq command & restart link */ + aq_error = i40e_aq_set_phy_config(hw, &config, NULL); + if (aq_error) { + device_printf(dev, "%s: Error setting new phy config %d," + " aq error: %d\n", __func__, aq_error, + hw->aq.asq_last_status); + return (EAGAIN); + } + + return (0); +} + /* ** Control link advertise speed: ** Flags: @@ -4315,10 +4395,7 @@ ixl_set_advertise(SYSCTL_HANDLER_ARGS) struct ixl_pf *pf = (struct ixl_pf *)arg1; struct i40e_hw *hw = &pf->hw; device_t dev = pf->dev; - struct i40e_aq_get_phy_abilities_resp abilities; - struct i40e_aq_set_phy_config config; int requested_ls = 0; - enum i40e_status_code aq_error = 0; int error = 0; /* @@ -4343,39 +4420,9 @@ ixl_set_advertise(SYSCTL_HANDLER_ARGS) if (pf->advertised_speed == requested_ls) return (0); - /* Get current capability information */ - aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, FALSE, &abilities, NULL); - if (aq_error) { - device_printf(dev, "%s: Error getting phy capabilities %d," - " aq error: %d\n", __func__, aq_error, - hw->aq.asq_last_status); - return (EAGAIN); - } - - /* Prepare new config */ - bzero(&config, sizeof(config)); - config.phy_type = abilities.phy_type; - config.abilities = abilities.abilities - | I40E_AQ_PHY_ENABLE_ATOMIC_LINK; - config.eee_capability = abilities.eee_capability; - config.eeer = abilities.eeer_val; - config.low_power_ctrl = abilities.d3_lpan; - /* Translate into aq cmd link_speed */ - if (requested_ls & 0x4) - config.link_speed |= I40E_LINK_SPEED_10GB; - if (requested_ls & 0x2) - config.link_speed |= I40E_LINK_SPEED_1GB; - if (requested_ls & 0x1) - config.link_speed |= I40E_LINK_SPEED_100MB; - - /* Do aq command & restart link */ - aq_error = i40e_aq_set_phy_config(hw, &config, NULL); - if (aq_error) { - device_printf(dev, "%s: Error setting new phy config %d," - " aq error: %d\n", __func__, aq_error, - hw->aq.asq_last_status); - return (EAGAIN); - } + error = ixl_set_advertised_speeds(pf, requested_ls); + if (error) + return (error); pf->advertised_speed = requested_ls; ixl_update_link_status(pf); @@ -4454,6 +4501,26 @@ ixl_get_bus_info(struct i40e_hw *hw, dev return (link); } +static int +ixl_sysctl_show_fw(SYSCTL_HANDLER_ARGS) +{ + struct ixl_pf *pf = (struct ixl_pf *)arg1; + struct i40e_hw *hw = &pf->hw; + char buf[32]; + + snprintf(buf, sizeof(buf), + "f%d.%d a%d.%d n%02x.%02x e%08x", + hw->aq.fw_maj_ver, hw->aq.fw_min_ver, + hw->aq.api_maj_ver, hw->aq.api_min_ver, + (hw->nvm.version & IXL_NVM_VERSION_HI_MASK) >> + IXL_NVM_VERSION_HI_SHIFT, + (hw->nvm.version & IXL_NVM_VERSION_LO_MASK) >> + IXL_NVM_VERSION_LO_SHIFT, + hw->nvm.eetrack); + return (sysctl_handle_string(oidp, buf, strlen(buf), req)); +} + + #ifdef IXL_DEBUG static int ixl_sysctl_link_status(SYSCTL_HANDLER_ARGS) @@ -4563,7 +4630,7 @@ ixl_sysctl_sw_filter_list(SYSCTL_HANDLER #define IXL_SW_RES_SIZE 0x14 static int -ixl_sysctl_hw_res_info(SYSCTL_HANDLER_ARGS) +ixl_sysctl_hw_res_alloc(SYSCTL_HANDLER_ARGS) { struct ixl_pf *pf = (struct ixl_pf *)arg1; struct i40e_hw *hw = &pf->hw; @@ -4620,7 +4687,120 @@ ixl_sysctl_hw_res_info(SYSCTL_HANDLER_AR device_printf(dev, "sysctl error: %d\n", error); sbuf_delete(buf); return error; +} + +/* +** Caller must init and delete sbuf; this function will clear and +** finish it for caller. +*/ +static char * +ixl_switch_element_string(struct sbuf *s, u16 seid, bool uplink) +{ + sbuf_clear(s); + if (seid == 0 && uplink) + sbuf_cat(s, "Network"); + else if (seid == 0) + sbuf_cat(s, "Host"); + else if (seid == 1) + sbuf_cat(s, "EMP"); + else if (seid <= 5) + sbuf_printf(s, "MAC %d", seid - 2); + else if (seid <= 15) + sbuf_cat(s, "Reserved"); + else if (seid <= 31) + sbuf_printf(s, "PF %d", seid - 16); + else if (seid <= 159) + sbuf_printf(s, "VF %d", seid - 32); + else if (seid <= 287) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411070616.sA76GBAX031650>